Skip to content

Commit

Permalink
change stetting path
Browse files Browse the repository at this point in the history
  • Loading branch information
goswinr committed Jan 12, 2025
1 parent 7f7c974 commit b45fba0
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 99 deletions.
19 changes: 19 additions & 0 deletions .github/InstallNotesNet48.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Install Notes

Just download and run `Fesh.net48-win-Setup.exe` to install.

No admin rights are required to install or run the app.
The app will be installed in `C:\Users\{username}\AppData\Local\Fesh.net48\current`.\
A shortcut will be created on the desktop.\

It will automatically suggest to update Fesh when a new version is released.\
The installer is digitally code-signed via Azure Trusted Signing Service.\
It should not raise any security warnings.

There is also a portable package `Fesh.net48-Portable.zip` which does not need to be installed and is self-updating.\
Feel free to extract your app from that zip and place it wherever you'd like.

See the [Changelog](https://github.com/goswinr/Fesh/blob/main/CHANGELOG.md) for changes in this release

This release was created with the help of [Velopack](https://velopack.io/).
```
4 changes: 2 additions & 2 deletions .github/InstallNotesNet9.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Just download and run `Fesh-net9-Setup.exe` to install.
No admin rights are required to install or run the app.
The app will be installed in `C:\Users\{username}\AppData\Local\Fesh\current`.\
A shortcut will be created on the desktop.\
In the parent folder will be a file `Update.exe`.\
It will automatically update Fesh when a new version is released.\

It will automatically suggest to update Fesh when a new version is released.\
The installer is digitally code-signed via Azure Trusted Signing Service.\
It should not raise any security warnings.

Expand Down
53 changes: 40 additions & 13 deletions .github/workflows/release-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:
--framework net9.0-windows `
--no-self-contained
# - name: Run dotnet publish net48
# run: |
# dotnet publish FeshStandalone.fsproj `
# --configuration release `
# --runtime win-x64 `
# --output bin/publish/net48 `
# --framework net48 `
# --no-self-contained
- name: Run dotnet publish net48
run: |
dotnet publish FeshStandalone.fsproj `
--configuration release `
--runtime win-x64 `
--output bin/publish/net48 `
--framework net48 `
--no-self-contained
- name: Check version consistency of git tag and CHANGELOG.md
# needs in fsproj:
Expand Down Expand Up @@ -78,21 +78,48 @@ jobs:
# --token ${{secrets.GITHUB_TOKEN}} `
# --outputDir bin/installer/net9.0 `
# --channel net9
- name: Pack, Sign and Release with Velopack

- name: Pack, Sign and Release with Velopack .NET Framework 4.8
# https://docs.velopack.io/reference/cli/content/vpk-windows
# If you are publishing your application with --no-self-contained, then you should provide the --framework argument. https://docs.velopack.io/packaging/bootstrapping
run: |
dotnet tool install vpk --global
vpk pack `
--packId Fesh.App `
--packId Fesh.net48 `
--packVersion ${{github.ref_name}} `
--packDir bin/publish/net48 `
--mainExe Fesh.exe `
--framework net48 `
--icon Media/logoInstaller.ico `
--packAuthors "Goswin R" `
--releaseNotes .github/InstallNotesNet48.md `
--azureTrustedSignFile .github/signing-metadata.json `
--splashImage Media/logo.png `
--outputDir bin/installer/net48
vpk upload github `
--publish `
--repoUrl https://github.com/goswinr/Fesh `
--releaseName "Fesh ${{github.ref_name}} for .NET Framework 4.8" `
--tag ${{github.ref_name}} `
--token ${{secrets.GITHUB_TOKEN}} `
--outputDir bin/installer/net48
- name: Pack, Sign and Release with Velopack .NET 9.0
# https://docs.velopack.io/reference/cli/content/vpk-windows
# If you are publishing your application with --no-self-contained, then you should provide the --framework argument. https://docs.velopack.io/packaging/bootstrapping
run: |
dotnet tool install vpk --global
vpk pack `
--packId Fesh `
--packVersion ${{github.ref_name}} `
--packDir bin/publish/net9.0 `
--mainExe Fesh.exe `
--framework net9.0-x64-desktop `
--icon Media/logoInstaller.ico `
--packAuthors "Goswin R" `
--verbose `
--releaseNotes .github/InstallNotesNet9.md `
--azureTrustedSignFile .github/signing-metadata.json `
--splashImage Media/logo.png `
Expand All @@ -102,10 +129,10 @@ jobs:
vpk upload github `
--publish `
--repoUrl https://github.com/goswinr/Fesh `
--releaseName "Fesh ${{github.ref_name}}" `
--releaseName "Fesh ${{github.ref_name}} for .NET 9.0" `
--tag ${{github.ref_name}} `
--token ${{secrets.GITHUB_TOKEN}} `
--outputDir bin/installer/net9.0 `
--channel net9
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.17.0] - 2024-12-14
## [0.18.0] - 2024-12-14
### Changed
- changed install Folder for Velopack to `.\AppData\Local\Fesh.App\`
- changed Settings Folder to `.\AppData\Local\Fesh.App.Settings\`
- changed install Folder for Velopack to `.\AppData\Local\Fesh.net48\` for .Net 4.8
- changed Settings Folder to `.\AppData\Local\Fesh.Settings\` or `.\AppData\Local\Fesh.{host}.Settings\`

## [0.17.0] - 2024-12-14
### Changed
Expand Down
4 changes: 3 additions & 1 deletion Src/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ module App =
[< EntryPoint >]
[< STAThread >]
let runEditorStandalone (args: string []) : int =
VelopackApp.Build().Run() //https://docs.velopack.io/getting-started/csharp
VelopackApp.Build()
.SetAutoApplyOnStartup(false)
.Run() //https://docs.velopack.io/getting-started/csharp
let app = Application() // do first so that pack Uris work
let fesh = Initialize.everything (None, args)
current <- fesh
Expand Down
2 changes: 1 addition & 1 deletion Src/Config/AutoCompleteStatistic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type AutoCompleteStatistic ( runContext:RunContext) =

let sep = '=' // key value separator like in ini files

let filePath0 = runContext.GetPathToSaveAppData("AutoCompleteStatistic.txt")
let filePath0 = runContext.GetPathToSaveAppData("AutoComplete-Statistic.txt")

let writer = SaveReadWriter(filePath0,IFeshLog.printError)

Expand Down
2 changes: 1 addition & 1 deletion Src/Config/DefaultCode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open Fesh.Model

type DefaultCode (runContext:RunContext) =

let filePath0 = runContext.GetPathToSaveAppData("DefaultCode.fsx")
let filePath0 = runContext.GetPathToSaveAppData("Default-Code-for-New-Files.fsx")

let writer = SaveReadWriter(filePath0,IFeshLog.printError)

Expand Down
2 changes: 1 addition & 1 deletion Src/Config/FoldingStatus.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type FoldingStatus ( runContext:RunContext, recentlyUsedFiles:RecentlyUsedFiles)

let sep = '|' // separator

let filePath0 = runContext.GetPathToSaveAppData("FoldingStatus.txt")
let filePath0 = runContext.GetPathToSaveAppData("Folding-States.txt")

let writer = SaveReadWriter(filePath0,IFeshLog.printError)

Expand Down
8 changes: 2 additions & 6 deletions Src/Config/FsiArguments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ open Fesh.Model

type FsiArguments ( runContext:RunContext) =

let filePath0 = runContext.GetPathToSaveAppData("FsiArguments.txt")
let writer = SaveReadWriter(filePath0,IFeshLog.printError)
let filePath0 = runContext.GetPathToSaveAppData("FSI-Arguments.txt")
let writer = SaveReadWriter(filePath0, IFeshLog.printError)

let defaultArgs =
if runContext.IsHosted then // dec 2024, F# 9, on net48 hosted in Rhino --multiemit- is needed to enable multiple evaluations, line numbers for errors don't work though.
Expand Down Expand Up @@ -48,7 +48,6 @@ type FsiArguments ( runContext:RunContext) =
|> Array.filter (String.IsNullOrWhiteSpace>>not)
|> Array.filter (fun a -> a.ToLower() <> "--quiet") // this argument is managed separately in config.Settings and statusbar


let mutable args = [||]

///loads sync
Expand All @@ -62,9 +61,6 @@ type FsiArguments ( runContext:RunContext) =
member this.Reload() =
args <- get()
args



(*
note on docs:
--multiemit see: https://fsharp.github.io/fsharp-compiler-docs/fsi-emit.html
Expand Down
2 changes: 1 addition & 1 deletion Src/Config/OpenTabs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type FileToOpen = {file:FileInfo; makeCurrent:bool}
/// Files that are open when closing the editor window, for next restart
type OpenTabs (runContext:RunContext, startupArgs:string[]) =

let filePath0 = runContext.GetPathToSaveAppData("CurrentlyOpenFiles.txt")
let filePath0 = runContext.GetPathToSaveAppData("Currently-Open-Files.txt")
let writer = SaveReadWriter(filePath0,IFeshLog.printError)

let currentTabPreFix = "*Current tab:* " //a string that can never be part of a filename
Expand Down
2 changes: 1 addition & 1 deletion Src/Config/RecentlyUsedFiles.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type UsedFile = {

type RecentlyUsedFiles ( runContext:RunContext) =

let filePath0 = runContext.GetPathToSaveAppData("RecentlyUsedFiles.txt")
let filePath0 = runContext.GetPathToSaveAppData("Recently-Used-Files.txt")

let writer = SaveReadWriter(filePath0,IFeshLog.printError)

Expand Down
114 changes: 51 additions & 63 deletions Src/Config/RunContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open System.IO
/// mainWindowHandle: Pointer to main window(nativeInt),
/// fsiCanRun: a function to check if evaluation of fsi is currently allowed
/// logo: optional a URI to an alternative logo for hosted mode default is Uri("pack://application:,,,/Fesh;component/Media/logo.ico")
/// hostAssembly: to get version number of hosting assembly
type HostedStartUpData = {
hostName:string
mainWindowHandel: nativeint
Expand All @@ -21,45 +22,12 @@ type HostedStartUpData = {

module Folders =
let appDataLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)


let validHost(n:string)=
let mutable n = n
for c in IO.Path.GetInvalidFileNameChars() do
n <- n.Replace(c, '_') // make sure host name is a valid file name
if String.Equals(n, "App", StringComparison.OrdinalIgnoreCase) then
IFeshLog.log.PrintfnIOErrorMsg "Host name 'App' is reserved for the standalone Fesh app, changing to 'HostApp'"
n <- "HostApp"
n

let settingFile =
[|
"AutoCompleteStatistic.txt"
"CurrentlyOpenFiles.txt"
"DefaultCode.fsx"
"FoldingStatus.txt"
"FsiArguments.txt"
"PositionedWindow.txt"
"RecentlyUsedFiles.txt"
"Settings.txt"
|]

// restore settings files from version 0.15.0 or lower
let restoreSettingsFolder(oldFolder:string, newFolder:string) =
try
let oldSett = IO.Path.Combine(oldFolder, "Settings.txt")
let newSett = IO.Path.Combine(newFolder, "Settings.txt")
if IO.File.Exists oldSett && not ( IO.File.Exists newSett) then
for f in settingFile do
let oldFile= IO.Path.Combine(oldFolder, f)
let newFile = IO.Path.Combine(newFolder, f)
if IO.File.Exists oldFile && not (IO.File.Exists newFile) then
IO.File.Move(oldFile,newFile)
with e ->
IFeshLog.log.PrintfnIOErrorMsg $"Error while trying to restore old settings file: {e}"




open Folders

Expand All @@ -70,47 +38,29 @@ type RunContext (host:HostedStartUpData option) =
Runtime.InteropServices.RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.OrdinalIgnoreCase) |> not
//Type.GetType("System.Runtime.Loader.AssemblyLoadContext") <> null // https://github.com/dotnet/runtime/issues/22779#issuecomment-315527735


let appSuffix =
match host with
|None -> "App" // Standalone
|Some sd -> validHost sd.hostName

let settingsFolder =
let path = IO.Path.Combine(appDataLocal,$"Fesh.{appSuffix}.Settings")
let path =
match host with
|None ->
if isRunningOnDotNetCore then IO.Path.Combine(appDataLocal,$"Fesh.Settings") // Standalone
else IO.Path.Combine(appDataLocal,$"Fesh.net48.Settings") // Standalone .NET Framework
|Some sd -> IO.Path.Combine(appDataLocal,$"Fesh.{validHost sd.hostName}.Settings")
IO.Directory.CreateDirectory(path) |> ignore
path

let restoreSettingsFolderFromOldLocations() =
let oldFolder = // before version 0.15.0
match host with
|None -> IO.Path.Combine(appDataLocal, "Fesh") // Standalone
|Some _ -> IO.Path.Combine(appDataLocal, "Fesh", appSuffix)
restoreSettingsFolder(oldFolder, settingsFolder)
let oldFolder = // before version 0.17.0
match host with
|None -> IO.Path.Combine(appDataLocal, "Fesh", "Settings", "Standalone") // Standalone
|Some _ -> IO.Path.Combine(appDataLocal, "Fesh", "Settings", appSuffix)
restoreSettingsFolder(oldFolder, settingsFolder)


let settingsFileInfo =
IO.Path.Combine(settingsFolder, "Settings.txt")
|> IO.FileInfo

let positionedWindowSettingsFileInfo =
IO.Path.Combine(settingsFolder, "PositionedWindow.txt")
IO.Path.Combine(settingsFolder, "Position-of-Window-on-Screen.txt")
|> IO.FileInfo

do
restoreSettingsFolderFromOldLocations()

/// To get a path where to save the setting files, give file name including extension
member this.GetPathToSaveAppData (fileNameInclExt:string) =
IO.Path.Combine(settingsFolder, fileNameInclExt )

// member this.SettingsFolder = settingsFolder

member this.SettingsFileInfo = settingsFileInfo

member this.PositionedWindowSettingsFileInfo = positionedWindowSettingsFileInfo
Expand All @@ -134,7 +84,7 @@ type RunContext (host:HostedStartUpData option) =

/// opens up Explorer.exe
member this.OpenSettingsFolder()=
Diagnostics.Process.Start("explorer.exe", "\"" + settingsFolder+ "\"") |> ignore
Diagnostics.Process.Start("explorer.exe", "\"" + settingsFolder+ "\"") |> ignore

/// opens up Explorer.exe with folder of Fesh.exe
member this.OpenAppFolder()=
Expand All @@ -146,7 +96,45 @@ type RunContext (host:HostedStartUpData option) =
IFeshLog.log.PrintfnIOErrorMsg "Can get path of %A" ass.FullName
else
let folder = IO.Path.GetDirectoryName( ass.Location)
Diagnostics.Process.Start("explorer.exe", "\"" + folder+ "\"") |> ignore



Diagnostics.Process.Start("explorer.exe", "\"" + folder+ "\"") |> ignore

// let settingFile =
// [|
// "AutoCompleteStatistic.txt"
// "CurrentlyOpenFiles.txt"
// "DefaultCode.fsx"
// "FoldingStatus.txt"
// "FsiArguments.txt"
// "PositionedWindow.txt"
// "RecentlyUsedFiles.txt"
// "Settings.txt"
// |]

// // restore settings files from version 0.15.0 or lower
// let restoreSettingsFolder(oldFolder:string, newFolder:string) =
// try
// let oldSett = IO.Path.Combine(oldFolder, "Settings.txt")
// let newSett = IO.Path.Combine(newFolder, "Settings.txt")
// if IO.File.Exists oldSett && not ( IO.File.Exists newSett) then
// for f in settingFile do
// let oldFile= IO.Path.Combine(oldFolder, f)
// let newFile = IO.Path.Combine(newFolder, f)
// if IO.File.Exists oldFile && not (IO.File.Exists newFile) then
// IO.File.Move(oldFile,newFile)
// with e ->
// IFeshLog.log.PrintfnIOErrorMsg $"Error while trying to restore old settings file: {e}"




// let restoreSettingsFolderFromOldLocations() =
// let oldFolder = // before version 0.15.0
// match host with
// |None -> IO.Path.Combine(appDataLocal, "Fesh") // Standalone
// |Some _ -> IO.Path.Combine(appDataLocal, "Fesh", appSuffix)
// restoreSettingsFolder(oldFolder, settingsFolder)
// let oldFolder = // before version 0.17.0
// match host with
// |None -> IO.Path.Combine(appDataLocal, "Fesh", "Settings", "Standalone") // Standalone
// |Some _ -> IO.Path.Combine(appDataLocal, "Fesh", "Settings", appSuffix)
// restoreSettingsFolder(oldFolder, settingsFolder)
2 changes: 1 addition & 1 deletion Src/Config/ScriptCompilerTemplate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open Fesh.Model

type ScriptCompilerFsproj ( runContext:RunContext) =

let filePath0 = runContext.GetPathToSaveAppData("ScriptCompiler.fsproj")
let filePath0 = runContext.GetPathToSaveAppData("Script-Compiler-Template-Project.fsproj")

let writer = SaveReadWriter(filePath0,IFeshLog.printError)

Expand Down
Loading

0 comments on commit b45fba0

Please sign in to comment.