Skip to content

Commit

Permalink
fix: Use AppContext.BaseDirectory instead of Environment.CurrentDirec…
Browse files Browse the repository at this point in the history
…tory - dotnet#21750
  • Loading branch information
PreciousNyasulu committed Apr 12, 2024
1 parent 0a562dc commit f97b8d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/BlazorWebView/src/WindowsForms/BlazorWebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.AppContext;
using Microsoft.AspNetCore.Components.WebView.WebView2;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
Expand Down Expand Up @@ -177,7 +178,7 @@ private void StartWebViewCoreIfPossible()
}
else
{
appRootDir = Environment.CurrentDirectory;
}
}
var hostPageFullPath = Path.GetFullPath(Path.Combine(appRootDir, HostPage!)); // HostPage is nonnull because RequiredStartupPropertiesSet is checked above
var contentRootDirFullPath = Path.GetDirectoryName(hostPageFullPath)!;
Expand Down
3 changes: 2 additions & 1 deletion src/BlazorWebView/src/Wpf/BlazorWebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.AppContext;
using Microsoft.AspNetCore.Components.WebView.WebView2;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
Expand Down Expand Up @@ -262,7 +263,7 @@ private void StartWebViewCoreIfPossible()
}
else
{
appRootDir = Environment.CurrentDirectory;
appRootDir = AppContext.BaseDirectory;
}
var hostPageFullPath = Path.GetFullPath(Path.Combine(appRootDir, HostPage));
var contentRootDirFullPath = Path.GetDirectoryName(hostPageFullPath)!;
Expand Down

0 comments on commit f97b8d9

Please sign in to comment.