Skip to content

Commit

Permalink
Merge pull request #590 from ikvmnet/appctx
Browse files Browse the repository at this point in the history
Search for IKVM.Home and IKVM.Home.Root in AppContext
  • Loading branch information
wasabii authored Sep 10, 2024
2 parents f6fd873 + 26d92e4 commit ea6323f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/IKVM.Runtime/JVM.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ static string GetHomePath()
if (Directory.Exists(Path.GetFullPath(Path.Combine(ikvmHomeEntry.BasePath, ikvmHomeEntry.Value))))
return Path.GetFullPath(Path.Combine(ikvmHomeEntry.BasePath, ikvmHomeEntry.Value));

#if NET
// specified home directory in runtime.json, where path is relative to application
if (AppContext.GetData("IKVM.Home") is string confHome && !string.IsNullOrWhiteSpace(confHome))
if (Directory.Exists(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, confHome))))
return Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, confHome));
#endif

#if NETFRAMEWORK
// attempt to find settings in legacy app.config
try
Expand All @@ -153,6 +160,13 @@ static string GetHomePath()
if (ResolveHomePathFromRoot(Path.GetFullPath(Path.Combine(ikvmHomeRootEntry.BasePath, ikvmHomeRootEntry.Value))) is string ikvmHomeRootPath)
return ikvmHomeRootPath;

#if NET
// specified home root directory in runtime.json, where path is relative to application
if (AppContext.GetData("IKVM.Home.Root") is string confHomeRoot && !string.IsNullOrWhiteSpace(confHomeRoot))
if (ResolveHomePathFromRoot(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, confHomeRoot)) is string confHomeRootPath)
return confHomeRootPath;
#endif

#if NETFRAMEWORK
// attempt to find settings in legacy app.config
try
Expand Down

0 comments on commit ea6323f

Please sign in to comment.