diff --git a/src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj b/src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj index a1e10bdc677c..b006f79206a7 100644 --- a/src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj +++ b/src/Components/WebView/Samples/PhotinoPlatform/testassets/PhotinoTestApp/PhotinoTestApp.csproj @@ -5,6 +5,8 @@ Exe false false + <_WebViewAssetsBasePath>..\..\..\..\..\Web.JS\dist\Release\ + <_BlazorModulesFilePath>..\..\..\..\WebView\src\blazor.modules.json diff --git a/src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj b/src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj index 36045adf9ebd..2a3de09e531f 100644 --- a/src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj +++ b/src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj @@ -3,7 +3,6 @@ $(DefaultNetCoreTargetFramework) Build desktop applications with Blazor and a webview. - true Microsoft.Extensions.FileProviders.Embedded.Manifest.xml true $(DefineConstants);BLAZOR_WEBVIEW @@ -73,9 +72,11 @@ - - - + + + + diff --git a/src/Components/WebView/WebView/src/StaticContentProvider.cs b/src/Components/WebView/WebView/src/StaticContentProvider.cs index a2283943a182..026dbcc47560 100644 --- a/src/Components/WebView/WebView/src/StaticContentProvider.cs +++ b/src/Components/WebView/WebView/src/StaticContentProvider.cs @@ -12,8 +12,8 @@ internal sealed class StaticContentProvider private readonly Uri _appBaseUri; private readonly string _hostPageRelativePath; private static readonly FileExtensionContentTypeProvider ContentTypeProvider = new(); - private static readonly ManifestEmbeddedFileProvider _manifestProvider = - new ManifestEmbeddedFileProvider(typeof(StaticContentProvider).Assembly); + //private static readonly ManifestEmbeddedFileProvider _manifestProvider = + // new ManifestEmbeddedFileProvider(typeof(StaticContentProvider).Assembly); public StaticContentProvider(IFileProvider fileProvider, Uri appBaseUri, string hostPageRelativePath) { @@ -34,8 +34,8 @@ public bool TryGetResponseContent(string requestUri, bool allowFallbackOnHostPag // If there's no match, fall back on serving embedded framework content string contentType; var found = TryGetFromFileProvider(relativePath, out content, out contentType) - || (allowFallbackOnHostPage && TryGetFromFileProvider(_hostPageRelativePath, out content, out contentType)) - || TryGetFrameworkFile(relativePath, out content, out contentType); + || (allowFallbackOnHostPage && TryGetFromFileProvider(_hostPageRelativePath, out content, out contentType)); + //|| TryGetFrameworkFile(relativePath, out content, out contentType); if (found) { @@ -83,22 +83,22 @@ private bool TryGetFromFileProvider(string relativePath, out Stream content, out return false; } - private static bool TryGetFrameworkFile(string relativePath, out Stream content, out string contentType) - { - // We're not trying to simulate everything a real webserver does. We don't need to - // support querystring parameters, for example. It's enough to require an exact match. - var file = _manifestProvider.GetFileInfo(relativePath); - if (file.Exists) - { - content = file.CreateReadStream(); - contentType = GetResponseContentTypeOrDefault(relativePath); - return true; - } + //private static bool TryGetFrameworkFile(string relativePath, out Stream content, out string contentType) + //{ + // // We're not trying to simulate everything a real webserver does. We don't need to + // // support querystring parameters, for example. It's enough to require an exact match. + // var file = _manifestProvider.GetFileInfo(relativePath); + // if (file.Exists) + // { + // content = file.CreateReadStream(); + // contentType = GetResponseContentTypeOrDefault(relativePath); + // return true; + // } - content = default; - contentType = default; - return false; - } + // content = default; + // contentType = default; + // return false; + //} private static string GetResponseContentTypeOrDefault(string path) => ContentTypeProvider.TryGetContentType(path, out var matchedContentType) diff --git a/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props b/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props index f43c2047fb31..760bba3e973b 100644 --- a/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props +++ b/src/Components/WebView/WebView/src/build/Microsoft.AspNetCore.Components.WebView.props @@ -1,5 +1,45 @@ - _framework/blazor.modules.json + _framework/blazor.modules.json + false + + + $(ResolveStaticWebAssetsInputsDependsOn); + _AddBlazorWebViewAssets; + + + + + + <_WebViewAssetsBasePath Condition="'$(_WebViewAssetsBasePath)' == ''">$(MSBuildThisFileDirectory)..\staticwebassets\ + <_BlazorModulesFilePath Condition="'$(_WebViewAssetsBasePath)' == ''">$(MSBuildThisFileDirectory)..\staticwebassets\blazor.modules.json + + + <_WebViewAssetCandidates Include="$(_WebViewAssetsBasePath)blazor.webview.js"> + _framework/blazor.webview.js + + <_WebViewAssetCandidates Include="$(_BlazorModulesFilePath)" Condition="'@(_ExistingBuildJSModules)' == ''"> + _framework/blazor.modules.json + + + + + + + + + + + +