Skip to content

Commit

Permalink
new install path
Browse files Browse the repository at this point in the history
  • Loading branch information
goswinr committed Jan 11, 2025
1 parent 6773248 commit 7f7c974
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 38 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Dependabot for Nuget dependencies and Github Actions
version: 2
updates:
# Update to newer version of GitHub Actions
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ jobs:
# 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
dotnet tool install vpk --global
vpk pack `
--packId Fesh `
--packId Fesh.App `
--packVersion ${{github.ref_name}} `
--packDir bin/publish/net9.0 `
--mainExe Fesh.exe `
Expand All @@ -96,6 +95,7 @@ jobs:
--verbose `
--releaseNotes .github/InstallNotesNet9.md `
--azureTrustedSignFile .github/signing-metadata.json `
--splashImage Media/logo.png `
--outputDir bin/installer/net9.0 `
--channel net9
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ 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
### Changed
- changed install Folder for Velopack to `.\AppData\Local\Fesh.App\`
- changed Settings Folder to `.\AppData\Local\Fesh.App.Settings\`

## [0.17.0] - 2024-12-14
### Changed
- create a Velopack installer
Expand Down
89 changes: 54 additions & 35 deletions Src/Config/RunContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,80 @@ type HostedStartUpData = {
}

module Folders =
let appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
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 restoreSettingsFolderFromOldLocation(newFolder:string, startUpData:HostedStartUpData option) =
let restoreSettingsFolder(oldFolder:string, newFolder:string) =
try
let oldPath =
match startUpData with
|None -> IO.Path.Combine(appData, "Fesh") // Standalone
|Some sd -> IO.Path.Combine(appData, "Fesh", validHost sd.hostName)
let oldSett = IO.Path.Combine(oldPath, "Settings.txt")
let newSett = IO.Path.Combine(newFolder, "Settings.txt")
if IO.File.Exists oldSett && not ( IO.File.Exists newSett) then
for f in [| "AutoCompleteStatistic.txt"
"CurrentlyOpenFiles.txt"
"DefaultCode.fsx"
"FoldingStatus.txt"
"FsiArguments.txt"
"PositionedWindow.txt"
"RecentlyUsedFiles.txt"
"Settings.txt"
|] do
let oldFile= IO.Path.Combine(oldPath, f)
let newFile = IO.Path.Combine(newFolder, f)
if IO.File.Exists oldFile && not (IO.File.Exists newFile) then
IO.File.Move(oldFile,newFile)
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

/// A class to hold the current App Run context (Standalone or Hosted)
type RunContext (startUpData:HostedStartUpData option) =
type RunContext (host:HostedStartUpData option) =

let isRunningOnDotNetCore =
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 =
match startUpData with
|None -> IO.Path.Combine(appData, "Fesh", "Settings", "Standalone") // Standalone
|Some sd -> IO.Path.Combine(appData,"Fesh", "Settings", validHost sd.hostName)
let path = IO.Path.Combine(appDataLocal,$"Fesh.{appSuffix}.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
Expand All @@ -84,7 +103,7 @@ type RunContext (startUpData:HostedStartUpData option) =
|> IO.FileInfo

do
restoreSettingsFolderFromOldLocation(settingsFolder,startUpData)
restoreSettingsFolderFromOldLocations()

/// To get a path where to save the setting files, give file name including extension
member this.GetPathToSaveAppData (fileNameInclExt:string) =
Expand All @@ -96,20 +115,20 @@ type RunContext (startUpData:HostedStartUpData option) =

member this.PositionedWindowSettingsFileInfo = positionedWindowSettingsFileInfo

member this.FsiCanRun = match startUpData with None -> true | Some d -> d.fsiCanRun()
member this.FsiCanRun = match host with None -> true | Some d -> d.fsiCanRun()

member this.HostName = match startUpData with None -> None | Some d -> Some d.hostName
member this.HostName = match host with None -> None | Some d -> Some d.hostName

/// to get version number of hosting assembly
member this.HostAssembly = match startUpData with None -> None | Some d -> d.hostAssembly
member this.HostAssembly = match host with None -> None | Some d -> d.hostAssembly

member this.IsHosted = match startUpData with None -> false| Some _ -> true
member this.IsHosted = match host with None -> false| Some _ -> true

member this.IsStandalone = match startUpData with None -> true | Some _ -> false
member this.IsStandalone = match host with None -> true | Some _ -> false

member this.Logo = match startUpData with None -> None | Some d -> d.logo
member this.Logo = match host with None -> None | Some d -> d.logo

member this.DefaultCode = match startUpData with None -> None | Some sd -> sd.defaultCode
member this.DefaultCode = match host with None -> None | Some sd -> sd.defaultCode

member this.IsRunningOnDotNetCore = isRunningOnDotNetCore

Expand Down

0 comments on commit 7f7c974

Please sign in to comment.