From f97b8d9f4b3339f26c2d9cf1838e2906347f49fe Mon Sep 17 00:00:00 2001 From: Precious Nyasulu Date: Fri, 12 Apr 2024 10:36:01 +0000 Subject: [PATCH 1/4] fix: Use AppContext.BaseDirectory instead of Environment.CurrentDirectory - https://github.com/dotnet/maui/issues/21750 --- src/BlazorWebView/src/WindowsForms/BlazorWebView.cs | 3 ++- src/BlazorWebView/src/Wpf/BlazorWebView.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs index 0af5f6fc0198..8e54ff1580c0 100644 --- a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs +++ b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs @@ -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; @@ -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)!; diff --git a/src/BlazorWebView/src/Wpf/BlazorWebView.cs b/src/BlazorWebView/src/Wpf/BlazorWebView.cs index 98d6a68ca62f..544e7f5be8a6 100644 --- a/src/BlazorWebView/src/Wpf/BlazorWebView.cs +++ b/src/BlazorWebView/src/Wpf/BlazorWebView.cs @@ -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; @@ -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)!; From e638be89f3ec8d1b799c2ecba39cdd7788452dc1 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 16 Apr 2024 10:36:02 -0700 Subject: [PATCH 2/4] Update src/BlazorWebView/src/WindowsForms/BlazorWebView.cs Co-authored-by: Jonathan Peppers --- src/BlazorWebView/src/WindowsForms/BlazorWebView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs index 8e54ff1580c0..1795e993f0ba 100644 --- a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs +++ b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs @@ -178,7 +178,7 @@ private void StartWebViewCoreIfPossible() } else { - } + appRootDir = AppContext.BaseDirectory; } var hostPageFullPath = Path.GetFullPath(Path.Combine(appRootDir, HostPage!)); // HostPage is nonnull because RequiredStartupPropertiesSet is checked above var contentRootDirFullPath = Path.GetDirectoryName(hostPageFullPath)!; From e9cb3362cd7e8140d465a49ce87e5711d12041e2 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 16 Apr 2024 10:37:32 -0700 Subject: [PATCH 3/4] Update src/BlazorWebView/src/WindowsForms/BlazorWebView.cs --- src/BlazorWebView/src/WindowsForms/BlazorWebView.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs index 1795e993f0ba..5a54464ce022 100644 --- a/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs +++ b/src/BlazorWebView/src/WindowsForms/BlazorWebView.cs @@ -10,7 +10,6 @@ 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; From 4b03b54c117325d6bf46613404c8cba62c51e81b Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 16 Apr 2024 10:37:37 -0700 Subject: [PATCH 4/4] Update src/BlazorWebView/src/Wpf/BlazorWebView.cs --- src/BlazorWebView/src/Wpf/BlazorWebView.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BlazorWebView/src/Wpf/BlazorWebView.cs b/src/BlazorWebView/src/Wpf/BlazorWebView.cs index 544e7f5be8a6..af673607a2de 100644 --- a/src/BlazorWebView/src/Wpf/BlazorWebView.cs +++ b/src/BlazorWebView/src/Wpf/BlazorWebView.cs @@ -11,7 +11,6 @@ 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;