Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish failed #2

Closed
ElderJames opened this issue Jul 27, 2021 · 68 comments
Closed

Publish failed #2

ElderJames opened this issue Jul 27, 2021 · 68 comments

Comments

@ElderJames
Copy link

Hi there, I tried to install this package to https://github.com/ant-design-blazor/ant-design-blazor, but an exception occurred during the publishing process.

AntDesign.Docs.Wasm -> E:\antd\ant-design-blazor\site\AntDesign.Docs.Wasm\obj\Release\net5\browser-wasm\PubTmp\Out\
dotnet "C:\Users\shunj\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.4.1\build\../tools/net5/blazorwasm-prerendering-server.dll" -a "AntDesign.Docs.Wasm" -t "AntDesign.Docs.Wasm.App" -s "#app" -p "E:\antd\ant-design-blazor\site\AntDesign.Docs.Wasm\bin\Release\net5\publish" -i "E:\antd\ant-design-blazor\site\AntDesign.Docs.Wasm\obj\Release\net5\." -m "" -f "net5"
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-C:\Users\shunj\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.4.1\build\../tools/net5/blazorwasm-prerendering-server.dll does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
C:\Users\shunj\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.4.1\build\BlazorWasmPreRendering.Build.targets(33,5): Error MSB3073: The command "dotnet "C:\Users\shunj\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.4.1\build\../tools/net5/blazorwasm-prerendering-server.dll" -a "AntDesign.Docs.Wasm" -t "AntDesign.Docs.Wasm.App" -s "#app" -p "E:\antd\ant-design-blazor\site\AntDesign.Docs.Wasm\bin\Release\net5\publish" -i "E:\antd\ant-design-blazor\site\AntDesign.Docs.Wasm\obj\Release\net5\." -m "" -f "net5"" exited with code 1.

@jsakamoto
Copy link
Owner

Thank you for reporting!

But unfortunately, I found out AntDesign.Docs.Wasm cannot pre-render to static files at this time.
I'll explain what's the matter below.

Anyway, we can progress static pre-rendering task of AntDesign.Docs.Wasm.

At first, please update the package reference to this package to v.1.0.0-preview.6.
Then, the error you saw and reported to me should be gone.
(I could fix the first problem (see also commit 1d5a0aea) with your report. Thanks!)

Second, maybe you already know, the Program.cs in the AntDesign.Docs.Wasm project has to change as below:

Before:

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("app");

        builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        builder.Services.AddAntDesignDocs(); // 👈 extract this line to...

        await builder.Build().RunAsync();
    }
}

After:

public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("app");

        builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        ConfigureServices(builder.Services);

        await builder.Build().RunAsync();
    }

    // 👇 ...to this static method. The method name and signature must be as below.
    private static void ConfigureServices(IServiceCollection services)
    {
        services.AddAntDesignDocs();
    }
}

After doing the above steps, the dotnet publish task on the AntDesign.Docs.Wasm project folder will be complete successfully.

However, the result of static pre-rendering will be empty....!

Because, when the request URL is "/", your ConventionRouter implementation just redirects, doesn't render anything.

And also, when the request URL is "/en-US", the server-side rendering process will crash with an unhandled exception.
You can reproduce this behavior on the AntDesign.Docs.Server.

(After initial launched of the AntDesign.Docs.Server app and you are redirected to "/en-US", then please reload it. You will see an error page like below)

image

If you fix the crash of the AntDesign.Docs.Server above, then I might be able to come up with something static pre-rendering be a success, so please let me know.

@fingers10
Copy link
Contributor

fingers10 commented Dec 1, 2021

@jsakamoto I appreciate your time in creating this project. I tried this with brand new net6.0 blazor wasm pwa project in windows 11 pro. I'm getting the below error on publish.

Publishing Log:
BlazorWasmPreRenderGitDeploy -> C:\Users\Abdul Rahman\source\repos\BlazorWasmPreRenderGitDeploy\BlazorWasmPreRenderGitDeploy\obj\Release\net6.0\browser-wasm\PubTmp\Out\
dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.9.0\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "BlazorWasmPreRenderGitDeploy" -t "BlazorWasmPreRenderGitDeploy.App" --selectorofrootcomponent "#app,app" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\BlazorWasmPreRenderGitDeploy\BlazorWasmPreRenderGitDeploy\bin\Release\net6.0\publish" -i "C:\Users\Abdul Rahman\source\repos\BlazorWasmPreRenderGitDeploy\BlazorWasmPreRenderGitDeploy\obj\Release\net6.0\." -m "" -f "net6.0"
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'BlazorWasmPreRenderGitDeploy, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'BlazorWasmPreRenderGitDeploy, Culture=neutral, PublicKeyToken=null'
   at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssembly(String assemblyName) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 41
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.BuildPrerenderingOptions(CustomAssemblyLoader assemblyLoader, CommandLineOptions commandLineOptions) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 70
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.Main(String[] args) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 24
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.<Main>(String[] args)
C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.9.0\build\BlazorWasmPreRendering.Build.targets(36,5): Error MSB3073: The command "dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.9.0\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "BlazorWasmPreRenderGitDeploy" -t "BlazorWasmPreRenderGitDeploy.App" --selectorofrootcomponent "#app,app" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\BlazorWasmPreRenderGitDeploy\BlazorWasmPreRenderGitDeploy\bin\Release\net6.0\publish" -i "C:\Users\Abdul Rahman\source\repos\BlazorWasmPreRenderGitDeploy\BlazorWasmPreRenderGitDeploy\obj\Release\net6.0\." -m "" -f "net6.0"" exited with code -532462766.
Output log:
[1D00:071C][2021-11-21T14:21:06]i001: Burn v3.10.4.4718, Windows v10.0 (Build 22000: Service Pack 0), path: C:\Windows\Temp\{AA2CFFB3-2680-45AB-89E0-7D3A9DF09CBD}\.cr\VC_redist.x64.exe
[1D00:071C][2021-11-21T14:21:06]i009: Command Line: '-burn.clean.room=C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14.Latest,version=14.30.30704,chip=x64\VC_redist.x64.exe -burn.filehandle.attached=696 -burn.filehandle.self=540 /q /norestart /log C:\Users\Abdul Rahman\AppData\Local\Temp\dd_setup_20211121142023_019_Microsoft.VisualCpp.Redist.14.Latest.log'
[1D00:071C][2021-11-21T14:21:06]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14.Latest,version=14.30.30704,chip=x64\VC_redist.x64.exe'
[1D00:071C][2021-11-21T14:21:06]i000: Setting string variable 'WixBundleOriginalSourceFolder' to value 'C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14.Latest,version=14.30.30704,chip=x64\'
[1D00:071C][2021-11-21T14:21:06]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\Abdul'
[1D00:071C][2021-11-21T14:21:06]i000: Setting string variable 'WixBundleManufacturer' to value 'Microsoft Corporation'
[1D00:2CC4][2021-11-21T14:21:06]i000: Setting version variable 'WixBundleFileVersion' to value '14.30.30704.0'
[1D00:071C][2021-11-21T14:21:06]i100: Detect begin, 11 packages
[1D00:071C][2021-11-21T14:21:06]i000: Setting string variable 'Arm64_Check' to value 'AMD64'
[1D00:071C][2021-11-21T14:21:06]i000: Setting version variable 'windows_uCRT_DetectKey' to value '10.0.22000.1'
[1D00:071C][2021-11-21T14:21:06]i000: Setting numeric variable 'windows_uCRT_DetectKeyExists' to value 1
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.3 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.3 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.2 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.2 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.1 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.1 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.0 AND NOT VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT = v6.0 AND VersionNT64) AND (windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10240.0)' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows81_x86, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows81_x64, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows8_x86, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows8_x64, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows7_MSU_x86, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: Windows7_MSU_x64, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: WindowsVista_MSU_x86, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: WindowsVista_MSU_x64, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: vcRuntimeMinimum_x64, state: Present, cached: Complete
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: vcRuntimeAdditional_x64, state: Present, cached: Complete
[1D00:071C][2021-11-21T14:21:06]i101: Detected package: vcRuntime_arm64, state: Absent, cached: None
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT >= v6.1 OR (VersionNT = v6.0 AND ServicePackLevel >= 2)' evaluates to true.
[1D00:071C][2021-11-21T14:21:06]i199: Detect complete, result: 0x0
[1D00:071C][2021-11-21T14:21:06]i200: Plan begin, 11 packages, action: Modify
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.3 AND NOT VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows81_x86
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.3 AND VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows81_x64
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.2 AND NOT VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows8_x86
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.2 AND VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows8_x64
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.1 AND NOT VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x86
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.1 AND VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x64
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.0 AND NOT VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x86
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'VersionNT = v6.0 AND VersionNT64' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x64
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT64) AND NOT (Arm64_Check = "ARM64")' evaluates to true.
[1D00:071C][2021-11-21T14:21:06]i052: Condition '(VersionNT64) AND NOT (Arm64_Check = "ARM64")' evaluates to true.
[1D00:071C][2021-11-21T14:21:06]i052: Condition 'Arm64_Check = "ARM64"' evaluates to false.
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows81_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows81_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows8_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows8_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows7_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: Windows7_MSU_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: WindowsVista_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: WindowsVista_MSU_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: vcRuntimeMinimum_x64, state: Present, default requested: Present, ba requested: Present, execute: None, rollback: None, cache: No, uncache: No, dependency: Register
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: vcRuntimeAdditional_x64, state: Present, default requested: Present, ba requested: Present, execute: None, rollback: None, cache: No, uncache: No, dependency: Register
[1D00:071C][2021-11-21T14:21:06]i201: Planned package: vcRuntime_arm64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
[1D00:071C][2021-11-21T14:21:06]i299: Plan complete, result: 0x0
[1D00:071C][2021-11-21T14:21:06]i300: Apply begin
[1D00:071C][2021-11-21T14:21:06]i010: Launching elevated engine process.
[1D00:071C][2021-11-21T14:21:06]i011: Launched elevated engine process.
[1D00:071C][2021-11-21T14:21:06]i012: Connected to elevated engine.
[2D10:1F98][2021-11-21T14:21:06]i358: Pausing automatic updates.
[2D10:1F98][2021-11-21T14:21:06]i359: Paused automatic updates.
[2D10:1F98][2021-11-21T14:21:06]i360: Creating a system restore point.
[2D10:1F98][2021-11-21T14:21:06]w363: Could not create system restore point, error: 0x80070422. Continuing...
[2D10:1F98][2021-11-21T14:21:06]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{57a73df6-4ba9-4c1d-bbbb-517289ff6c13}, resume: Active, restart initiated: No, disable resume: No
[2D10:1F98][2021-11-21T14:21:06]i325: Registering dependency: {57a73df6-4ba9-4c1d-bbbb-517289ff6c13} on package provider: Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v14, package: vcRuntimeMinimum_x64
[2D10:1F98][2021-11-21T14:21:06]i325: Registering dependency: {57a73df6-4ba9-4c1d-bbbb-517289ff6c13} on package provider: Microsoft.VS.VC_RuntimeAdditionalVSU_amd64,v14, package: vcRuntimeAdditional_x64
[2D10:1F98][2021-11-21T14:21:06]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{57a73df6-4ba9-4c1d-bbbb-517289ff6c13}, resume: ARP, restart: None, disable resume: No
[2D10:1F98][2021-11-21T14:21:06]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{57a73df6-4ba9-4c1d-bbbb-517289ff6c13}, resume: ARP, restart initiated: No, disable resume: No
[1D00:071C][2021-11-21T14:21:06]i399: Apply complete, result: 0x0, restart: None, ba requested restart:  No
[1D00:071C][2021-11-21T14:21:06]i500: Shutting down, exit code: 0x0
[1D00:071C][2021-11-21T14:21:06]i410: Variable: Arm64_Check = AMD64
[1D00:071C][2021-11-21T14:21:06]i410: Variable: SystemFolder = C:\Windows\system32\
[1D00:071C][2021-11-21T14:21:06]i410: Variable: VersionNT = 10.0.0.0
[1D00:071C][2021-11-21T14:21:06]i410: Variable: VersionNT64 = 10.0.0.0
[1D00:071C][2021-11-21T14:21:06]i410: Variable: windows_uCRT_DetectKey = 10.0.22000.1
[1D00:071C][2021-11-21T14:21:06]i410: Variable: windows_uCRT_DetectKeyExists = 1
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleAction = 6
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleElevated = 1
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleFileVersion = 14.30.30704.0
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleInstalled = 1
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleLog = C:\Users\Abdul
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleManufacturer = Microsoft Corporation
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleName = Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.30.30704
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleOriginalSource = C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14,version=14.30.30704,chip=x64\VC_redist.x64.exe
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleOriginalSourceFolder = C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14,version=14.30.30704,chip=x64\
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleProviderKey = VC,redist.x64,amd64,14.30,bundle
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleSourceProcessFolder = C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14.Latest,version=14.30.30704,chip=x64\
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleSourceProcessPath = C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.VisualCpp.Redist.14.Latest,version=14.30.30704,chip=x64\VC_redist.x64.exe
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleTag = 
[1D00:071C][2021-11-21T14:21:06]i410: Variable: WixBundleVersion = 14.30.30704.0
[1D00:071C][2021-11-21T14:21:06]i007: Exit code: 0x0, restarting: No

Project Repo Link - https://github.com/fingers10/BlazorWasmPreRenderGitDeploy

Please can you assist me on this?

@jsakamoto
Copy link
Owner

@fingers10 Thank you for your feedback!

I want to make the "BlazorWasmPreRendering.Build" work well on your scenario.
But I think it is not so easy.

I appreciate you if you will be patiently waiting to finish my work.

@fingers10
Copy link
Contributor

@jsakamoto thanks for the inputs. I'll wait for the solution. Please could you let me know what is the issue here?

@jsakamoto
Copy link
Owner

@fingers10

Please could you let me know what is the issue here?

Yes, of course, but I have no idea at this time.
So I have to investigate it from the start.

However, you have disclosed your repository to me that can reproduce failing. It is much helpful to resolve this issue!

@jsakamoto
Copy link
Owner

[Progress Report]

Sorry too late but recently I've been able to try to resolve your problem.

And I found the problem can be reproduced when I execute publishing the project with Visual Studio 2022.

I'm currently working on this issue, and I think I can finally resolve that unhandled exception error.

@jsakamoto
Copy link
Owner

@fingers10

I did it!

Could you try the latest version of the "BlazorWasmPreRendering.Build" out?

@fingers10
Copy link
Contributor

fingers10 commented Dec 13, 2021

@jsakamoto

Many thanks for your time and response. This works for simple project. But If we have a parameter of Type WebAssemblyHostConfiguration in ConfigureServices. This fails with below error.

Error:
PrerenderTest -> C:\Users\Abdul Rahman\source\repos\PrerenderTest\PrerenderTest\obj\Release\net6.0\browser-wasm\PubTmp\Out\
dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.10.1\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "PrerenderTest" -t "PrerenderTest.App" --selectorofrootcomponent "#body" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\PrerenderTest\PrerenderTest\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\PrerenderTest\PrerenderTest\obj\Release\net6.0\." -m "" -f "net6.0"
Unhandled exception. System.TypeLoadException: Method 'get_Item' in type 'Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostConfiguration' from assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Reflection.RuntimeMethodInfo.<get_Signature>g__LazyCreateSignature|24_0()
   at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
   at System.Reflection.RuntimeMethodInfo.GetParameters()
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Startup.ConfigureApplicationServices(IServiceCollection services, String baseAddress) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Startup.cs:line 54
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Startup.ConfigureServices(IServiceCollection services) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Startup.cs:line 33
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.StartWebHostAsync(BlazorWasmPrerenderingOptions prerenderingOptions) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 218
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.Main(String[] args) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 28
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.<Main>(String[] args)
C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.10.1\build\BlazorWasmPreRendering.Build.targets(44,5): Error MSB3073: The command "dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.10.1\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "PrerenderTest" -t "PrerenderTest.App" --selectorofrootcomponent "#body" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\PrerenderTest\PrerenderTest\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\PrerenderTest\PrerenderTest\obj\Release\net6.0\." -m "" -f "net6.0"" exited with code -532462766.

Project Repo Link - https://github.com/fingers10/PrerenderTest

@jsakamoto
Copy link
Owner

@fingers10

The pre-rendering process invokes your ConfigurationServices static method, but the process can't treat the type for the WebAssembly platform because the pre-rendering process and your code runs on a normal ASP.NET Core server process, not on the web browser!

image

In this case, if you simply remove the 3rd argument from the ConfigurationServices static method, the publishing process should be done successfully.

But, I've guessed that you want to do something by using the 3rd WebAssemblyHostConfiguration argument.
What do you want to do by using WebAssemblyHostConfiguration?
Do you want to access the IConfiguration application configuration?

The current version of "BlazorWasmPreRendering.Build" has no that ability, but I'll consider improving this library to be able to provide IConfiguration to the user's ConfigureServices static method if you hope it.

@fingers10
Copy link
Contributor

@jsakamoto

I have appsettings.json in my wwwroot and I'm binding some configuration from that and hence I need acces to configuration.

I tried with IConfiguration instead of WebAssemblyHostConfiguration. The code compiles without any error but fails on publish.

Please can you assist?

@jsakamoto
Copy link
Owner

@fingers10

I tried with IConfiguration instead of WebAssemblyHostConfiguration. The code compiles without any error but fails on publish.

Yeah, the current version of "BlazorWasmPreRendering.Build" cannot provide the IConfiguration to any ConfigureService() static method during the publishing process.

So, I'll improve "BlazorWasmPreRendering.Build" and make it be able to provide the IConfiguration to any ConfigureService() static method during the publishing process.

Would you please give me more days to improve it if you hope it?

Anyway, thank you for letting me know your scenario! 👍

@fingers10
Copy link
Contributor

Sure. I'll wait for it. Happy to hear back.

@jsakamoto
Copy link
Owner

@fingers10

I published the new version of "BlazorWasmPreRendering.Build".

This version will provide an IConfiguration object to the application's "ConfigureServices()" method as an argument.

Please update the package version, and please rewrite your ConfigureServices method code like this:

From:

static void ConfigureServices(..., WebAssemblyHostConfiguration configuration)
{
    ...

To:

static void ConfigureServices(..., IConfiguration configuration)
{
    ...

By the way, please remember that the pre-rendering process is a normal ASP.NET Core server-side process.

Your code runs on an ASP.NET Core server during the publishing and pre-rendering, not on a Web browser.

That means, if your code access any kind of web browser-specific objects or services at the "OnInitilized", such as invoking JavaScript, it crushes the pre-rendering process again.
So you have to place that kind of code in the "OnAfterRender".

@fingers10
Copy link
Contributor

fingers10 commented Dec 15, 2021

@jsakamoto This now worked for simple project. Howerver this fails in my production blazor project.

Web.csproj:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

	<PropertyGroup>
		<TargetFramework>net6.0</TargetFramework>
		<LangVersion>latest</LangVersion>
		<Nullable>enable</Nullable>
		<ImplicitUsings>enable</ImplicitUsings>
		<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
		<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
		<BlazorWasmPrerenderingRootComponentSelector>#body</BlazorWasmPrerenderingRootComponentSelector>
		<!--<AnalysisMode>AllEnabledByDefault</AnalysisMode>-->
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="BlazorWasmPreRendering.Build" Version="1.0.0-preview.11.0" />
Program.cs:
var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));

builder.RootComponents.Add<App>("#body");
builder.RootComponents.Add<HeadOutlet>("head::after");

ConfigureServices(builder.Services, builder.Configuration);

await builder.Build().RunAsync();

static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
Index.razor.cs:
public class IndexBase : ComponentBase, IDisposable
{
    private readonly CancellationTokenSource _cancellationTokenSource = new();

    [Inject] private IDashboardDataService DashboardDataService { get; set; }
    
    //protected override async Task OnInitializedAsync()
    //{
    //    var result = await DashboardDataService._(_cancellationTokenSource.Token);

    //    await _();
    //}

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            var result = await DashboardDataService._(_cancellationTokenSource.Token);

            await _();

            await __();
        }
    }
Error Logs:
Web -> C:\Users\Abdul Rahman\source\repos\fingers10\xxxx\Web\obj\Release\net6.0\browser-wasm\PubTmp\Out\
dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.11.0\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "Web" -t "Web.App" --selectorofrootcomponent "#body" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\fingers10\xxxx\Web\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\fingers10\xxxx\Web\obj\Release\net6.0\." -m "" -f "net6.0"
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.IndexHtmlFragments.Load(String indexHtmlPath, String selectorOfRootComponent, String selectorOfHeadOutletComponent) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\IndexHtmlFragments.cs:line 65
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.BuildPrerenderingOptions(CustomAssemblyLoader assemblyLoader, CommandLineOptions commandLineOptions) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 90
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.Main(String[] args) in C:\Project\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 25
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.<Main>(String[] args)
C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.11.0\build\BlazorWasmPreRendering.Build.targets(44,5): Error MSB3073: The command "dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.11.0\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "Web" -t "Web.App" --selectorofrootcomponent "#body" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\fingers10\xxxx\Web\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\fingers10\xxxx\Web\obj\Release\net6.0\." -m "" -f "net6.0"" exited with code -532462766.

Am I doing anything wrong here?

@fingers10
Copy link
Contributor

fingers10 commented Dec 16, 2021

@jsakamoto never mind. I figured out the build error issue. I apologise. I forgot to add id="body" in my <body> tag in index.html. After changing to <body id="body" .. publish succeeded. But here comes the new surprise. The index.html has no prerendered content.

Index.html after publish:

index.html
<!DOCTYPE html>
<html class="h-full overflow-hidden">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!--<meta http-equiv="Content-Security-Policy"
          content="base-uri 'self';
                   block-all-mixed-content;
                   img-src data: https:;
                   object-src 'self';
                   script-src 'self'
                              'sha256-v8v3RKRPmN4odZ1CWM5gw80QKPCCWMcpNeOmimNL2AA='
                              'unsafe-eval';
                   style-src 'self'
                             'unsafe-inline';
                   upgrade-insecure-requests;">-->
    <title>Galla | The Shopkeeper App</title>
    <base href="/" />
    <link href="_content/BlazorDateRangePicker/daterangepicker.min.css" rel="stylesheet" />
    <link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />
    <link href="css/site.min.css" rel="stylesheet" />
    <link href="Web.styles.css" rel="stylesheet">
    <link href="manifest.json" rel="manifest" />
    <link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
</head>

<body id="body" class="h-full overflow-hidden">
    <section class="fixed inset-0 h-full w-full flex justify-center items-center bg-black opacity-75">
        <p class="text-white text-2xl font-bold"><i class="fas fa-circle-notch animate-spin"></i> Loading...</p>
    </section>

    <div id="blazor-error-ui" class="bg-red text-white fixed bottom-0 w-full z-50 p-2" style="display: none;">
        An unhandled error has occurred. Please click on
        <a href="javascript: void(0)" class="inline-block underline hover\:text-white" onclick="location.reload()">Reload</a>
        to proceed.
        <button class="delete dismiss fixed right-5 bottom-2"></button>
    </div>
    <script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
    <script src="_framework/blazor.webassembly.js"></script>
    <script src="js/Chart.js"></script>
    <script src="js/print.js"></script>
    <script src="js/pdf.js"></script>
    <script src="_content/BlazorDateRangePicker/clickAndPositionHandler.js"></script>
    <script src="js/blazorInterop.js"></script>
    <script>navigator.serviceWorker.register('service-worker.js');</script>
</body>

</html>

index.html is same before and after publish.

Now please can you further assist me on this?

@jsakamoto
Copy link
Owner

@fingers10 I'm sorry I had mistaken too.

(see also the commit message of: 105bc7c)

I've never tried your scenario yet, but anyway please consider try to the latest version if you can.

@fingers10
Copy link
Contributor

Sure I'll check and get back.

@fingers10
Copy link
Contributor

@jsakamoto still the same. No prerendering content in index.html after publish

@jsakamoto
Copy link
Owner

Could you execute the dotnet publish command below on your project folder?

dotnet publish -c:Release -v:n

I'm guessing the error message "The HTTP status code was not OK. (it was InternalServerError.)" would be shown in the build process output.

image

If so, you should be able also to see the prerendering command line text in the build process output.

image

Then please copy that prerendering command line text, paste it in the terminal console, append the "-k" switch, and press the Enter key.
The prerendering server will be launched and never exit until you enter the Ctrl+C key combination in the terminal console by the "-k" switch effect.

image

After doing that, please open the URL http://127.0.0.1:5050/ on your web browser.
Then you will see the details of errors on the browser, like below.

image

I appreciate it if you report the details of the errors.

@fingers10
Copy link
Contributor

fingers10 commented Feb 22, 2022

@jsakamoto Sorry for the delayed response.

Here are the requested details.

image

Error:

FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Stack Trace::
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
   at System.Runtime.Loader.AssemblyLoadContext.InternalLoad(ReadOnlySpan`1 arrAssembly, ReadOnlySpan`1 arrSymbols)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly, Stream assemblySymbols)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssemblyFrom(String assemblyDir, String assemblyName) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 31
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<>c__DisplayClass1_0.<.ctor>b__1(String dir) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 20
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<.ctor>b__1_0(AssemblyLoadContext context, AssemblyName name) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 19
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
Error:

FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)

Stack Trace:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)
File name: 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
 ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Components.WebAssembly, Version=6.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
   at System.Runtime.Loader.AssemblyLoadContext.InternalLoad(ReadOnlySpan`1 arrAssembly, ReadOnlySpan`1 arrSymbols)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly, Stream assemblySymbols)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.LoadAssemblyFrom(String assemblyDir, String assemblyName) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 31
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<>c__DisplayClass1_0.<.ctor>b__1(String dir) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 20
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.CustomAssemblyLoader.<.ctor>b__1_0(AssemblyLoadContext context, AssemblyName name) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\CustomAssemblyLoader.cs:line 19
   at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
   at System.Signature..ctor(Void* pCorSig, Int32 cCorSig, RuntimeType declaringType)
   at System.Reflection.RuntimePropertyInfo.get_Signature()
   at System.Reflection.RuntimePropertyInfo.get_PropertyType()
   at Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(Type type)
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent(Type componentType)
   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.CreateInitialRenderAsync(Type componentType, ParameterView initialParameters)
   at Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c__11`1.<<InvokeAsync>b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.PrerenderComponentAsync(ParameterView parameters, HttpContext httpContext, Type componentType)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.StaticComponentAsync(HttpContext context, Type type, ParameterView parametersCollection)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.RenderComponentAsync(ViewContext viewContext, Type componentType, RenderMode renderMode, Object parameters)
   at AspNetCoreGeneratedDocument.Pages__Host.ExecuteAsync() in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Pages\_Host.cshtml:line 5
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Prerendering-InternalServerError.zip

I have attached the complete HTML file for your reference.

@jsakamoto
Copy link
Owner

@fingers10 Thank you for letting me know!

I fixed this problem and published the new version.

Would you try it out?

Again, thank you for your contributions! 👍

@fingers10
Copy link
Contributor

@jsakamoto Sure I'll check and get back. I have one more question. This package supports PWA apps and also fixed integrity issues?

@jsakamoto
Copy link
Owner

@fingers10

This package supports PWA apps and also fixed integrity issues?

Yes, this package has been supported PWA apps correctly since the v.1.0.0-preview.12.0.

Of course, it has not been experienced a lot of real-world tests, but in my few cases, it looks to be working fine for PWA offline support.

@fingers10
Copy link
Contributor

fingers10 commented Feb 25, 2022

@jsakamoto This time I'm getting new error related to URI.

Console output:
Start fetching...[http://127.0.0.1:5050]
Getting http://127.0.0.1:5050/...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-lazy-loading...
  The HTTP status code was not OK. (it was InternalServerError.)
Getting http://127.0.0.1:5050/blogs/blazor-wasm-styles-and-css-isolation...
  The HTTP status code was not OK. (it was InternalServerError.)
Getting http://127.0.0.1:5050/blogs/blazor-wasm-javascript-interop-and-isolation...
  The HTTP status code was not OK. (it was InternalServerError.)
Getting http://127.0.0.1:5050/blogs/blazor-wasm-dark-theme-and-light-theme...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-exception-handling-and-error-boundary...
  The HTTP status code was not OK. (it was InternalServerError.)
Getting http://127.0.0.1:5050/blogs/blazor-wasm-error-logging...
Getting http://127.0.0.1:5050 void(0)...
Unhandled exception. System.UriFormatException: Invalid URI: Invalid port specified.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString, UriKind uriKind)
   at System.Net.Http.HttpClient.CreateUri(String uri)
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.StaticlizeCrawler.SaveToStaticFileAsync(String path) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\StaticlizeCrawler.cs:line 0
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.StaticlizeCrawler.SaveToStaticFileAsync(String path) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\StaticlizeCrawler.cs:line 86
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.StaticlizeCrawler.SaveToStaticFileAsync(String path) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\StaticlizeCrawler.cs:line 86
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.StaticlizeCrawler.SaveToStaticFileAsync(String path) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\StaticlizeCrawler.cs:line 86
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.PreRenderToStaticFilesAsync(CommandLineOptions commandLineOptions, CustomAssemblyLoader assemblyLoader, BlazorWasmPrerenderingOptions prerenderingOptions) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 50
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.Main(String[] args) in C:\Projects\Blazor\BlazorWasmPreRendering.Build\BlazorWasmPreRendering.Build\Program.cs:line 28
   at Toolbelt.Blazor.WebAssembly.PrerenderServer.Program.<Main>(String[] args)
C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.17.0\build\BlazorWasmPreRendering.Build.targets(47,5): Error MSB3073: The command "dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.17.0\build\../tools/net6.0/blazorwasm-prerendering-server.dll" -a "Web" -t "Web.App" --selectorofrootcomponent "#app,app" --selectorofheadoutletcomponent "head::after" -p "C:\Users\Abdul Rahman\source\repos\ilovedotnet\Web\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\ilovedotnet\Web\obj\Release\net6.0\." -m "" -f "net6.0" --serviceworkerassetsmanifest "service-worker-assets.js" -e "Production" -o "AppendHtmlExtension"" exited with code -532462766.

I'll develop a minimal repro sample and get back

@fingers10
Copy link
Contributor

@jsakamoto , I figured out. If any page has link with url fragment, then prerendering of that page fails.

<NavLink href="blogs/blazor-wasm-exception-handling-and-error-boundary#global-exception-handling" Match="NavLinkMatch.All">
    Global Exception Handling
</NavLink>

Parsing of URL with fragment fails?

@jsakamoto
Copy link
Owner

@fingers10 Thank you for a lot of reporting!

I improved this package and released the new version.

https://www.nuget.org/packages/BlazorWasmPreRendering.Build/1.0.0-preview.18.0

  • Added the "BlazorWasmPrerenderingKeepServer" MSBuild property for troubleshooting.
  • Improve: show the server response when the HTTP status code does not represent success.
  • Improve: just skip instead of a crash even if a URL to fetch next was not a valid format.

In this version, this package shows the response content string when the HTTP status code does not represent success.

image

I expect that improvement will be helpful to investigate and resolve server errors during the pre-rendering process.

And, this version has been supported the "BlazorWasmPrerenderingKeepServer" MSBuild property option.

Usually, the pre-rendering server is stopped automatically after the fetching process is completed.
Instead, if you specified the "BlazorWasmPrerenderingKeepServer" MSBuild property to "true", the pre-rendering server keeps running.

dotnet publish -c:Release -p:BlazorWasmPrerenderingKeepServer=true

During the pre-rendering server is running, you can investigate the Blazor apps running on the pre-rendering server.

image

Sorry to bother you, I appreciate it if you try the latest version of this package again.

@fingers10
Copy link
Contributor

fingers10 commented Feb 26, 2022

@jsakamoto, Prerendering and Publish is successful now.

  1. I noticed that prerendering is not replacing Loading... text in #app element. Instead it's appending with #app element content.

image

Is this the expected behavior?

  1. Inside <head> Tag, I noticed that a script tag is getting appeneded after all content inside <head>
<!-- %%-PRERENDERING-HEADOUTLET-END-%% -->
<script src="data:text/javascript;base64,KGZ1bmN0aW9uKG4sdCxpKXtmb3IodmFyIGY9bi5jcmVhdGVOb2RlSXRlcmF0b3IobiwxMjgpLHIsZSx1O2YubmV4dE5vZGUoKTspaWYocj1mLnJlZmVyZW5jZU5vZGUsdC50ZXN0KHIudGV4dENvbnRlbnQudHJpbSgpKSl7d2hpbGUoaT1yLm5leHRTaWJsaW5nKWlmKGU9aS50ZXh0Q29udGVudC50cmltKCksaS5yZW1vdmUoKSx0LnRlc3QoZSkpYnJlYWs7ci5yZW1vdmUoKTticmVha311PUFycmF5LmZyb20obi5xdWVyeVNlbGVjdG9yQWxsKCJzY3JpcHQiKSkucG9wKCk7dSYmdS5yZW1vdmUoKX0pKGRvY3VtZW50LC9eJSUtUFJFUkVOREVSSU5HLUhFQURPVVRMRVQtKEJFR0lOfEVORCktJSUkLyk7"></script>
</head>

Please can you explain on why this is getting added? My content-security-policy is not allowing this script to be executed.

  1. I also noticed that the respective index.hml pages are not stored inside correct folder path. For example,
blogs/article-1
blogs/article-2

Both the above urls get's saved inside blogs folder as article-1.html and article-2.html but it has to be saved in the below structure. I have previously worked with react-snap which will prerender and follow the below structure.

wwwroot/blogs/article-1/index.html
wwwroot/blogs/article-2/index.html

Please correct me if I'm wrong.

  1. And I noticed the below error from the prerendering output,
Getting http://127.0.0.1:5050 void(0)...
  [ERROR] The request URL (http://127.0.0.1:5050 void(0)) was not valid format.
Fetching complete.

@jsakamoto
Copy link
Owner

jsakamoto commented Feb 27, 2022

@fingers10

  1. I noticed that prerendering is not replacing Loading... text in #app element. Instead it's appending with #app element content.

That is by design at this time.

The prerendered contents can be visible immediately.
But while a few seconds, it can't interact with user operations until the Blazor runtime load all of the required files and has been started runtime.

Therefore, the "BlazorWasmPreRendering.Build" keeps the "Loading..." contents and makes the prerendered contents to be invisible for humans by CSS styling.
After the Blazor runtime has started, the contents inside the #app element are overwritten by the Blazor runtime.

That means only search engine crawlers can see the prerendered contents.
So the "BlazorWasmPreRendering.Build" aims only at SEO at this time.

However, if the developer knows these backgrounds, the developer does not need to take that strategy.

For example, the "ClickOnce Get" site ( https://clickonceget.azurewebsites.net/ ) that is built on Blazor WebAssembly shows prerendered contents to users immediately, but the buttons are disabled by CSS styling until the Blazor WebAssembly engine has been started.

👉

If developers understand this technic and can implement that controlling user interaction, the "BlazorWasmPreRendering.Build" should replace all of the contents inside the #app element without keeping "Loading..." contents.

Unfortunately, the "BlazorWasmPreRendering.Build" doesn't provide the option that replaces all of the contents inside of the #app element without keeping "Loading..." contents at this time.

However, currently, I'm considering implementing that option.

Appendix:
I know the "WebAssemblyPrerendered" render mode and transferring the state from the server-side prerendering process to the client-side Blazor WebAssembly process.
I'll also consider the "WebAssemblyPrerendered" render mode scenario.

@fingers10
Copy link
Contributor

@jsakamoto many thanks for your response. Please can you help me out with other queries in my previous comment?

@fingers10
Copy link
Contributor

fingers10 commented Mar 12, 2022

@jsakamoto, Many thanks. I'll try at the above response.

In PWA apps, index.html always loads the stale content even though published index.html has new content. Is there any way to forcibly fetch index.html from server when online and load index.html from cache when offline?

In general while publishing, if <BlazorWasmPrerenderingDeleteLoadingContents> is enabled, will it be good to replace loading text only in index.html and for remaining paths like /about/index.html can we replace loading text with respective page content?

Here is my view. Please share your thoughts on this.

when <BlazorWasmPrerenderingDeleteLoadingContents> is enabled,
wwwroot -> index.html - Replace Loading Text with index.html content

when <BlazorWasmPrerenderingDeleteLoadingContents> is enabled, For any other index.html like,
wwwroot/about -> index.html - Replace Loading Text with about page content
wwwroot/blog/article1 -> index.html - Replace Loading Text with article1 page content
wwwroot/blog/article2 -> index.html - Replace Loading Text with article2 page content

This way crawlers will have correct snapshot of all the pages.

And is there any other way we can avoid flickering effect when directly opening any routes other than index.html because index.html will have same content before and after blazor engine kicks in. For remaining pages index.html loads and then actual page loads.

@jsakamoto
Copy link
Owner

jsakamoto commented Mar 12, 2022

@fingers10

In PWA apps, index.html always loads the stale content even though published index.html has new content. Is there any way to forcibly fetch index.html from server when online and load index.html from cache when offline?

To my knowledge, the updated index.html contents in a PWA will be definitely reloaded automatically after you re-published the project, but the important thing is it will only happen after all browser instances are exited.

The browser's "reload" button doesn't have any effect.

I forget the source of that information, but I remember that I heard it is by the design of some web browser products.

However, if you are developing that PWA, you can reload forcibly using the Chromium browser's developer tools with the following steps.

  1. Turn on the "Disable cache" check box in the "Network" tab of the Chromium browser's developer tools window.

  1. Turn on the "Update on reload" check box in the "Service Workers" section of the "Application" tab.

  1. Click the "Clear site data" button in the "Storage" section of the "Application" tab.

  1. Right-click the browser's "Reload" button, and click the "Empty cache and hard refresh" menu item.

@jsakamoto
Copy link
Owner

jsakamoto commented Mar 12, 2022

@fingers10

In general while publishing, if is enabled, will it be good to replace loading text only in index.html and for remaining paths like /about/index.html can we replace loading text with respective page content?

No, all pre-rendered output will be replaced "Loading..." text with respective page content even it is the root index.html.

Particularly, the "Loading..." text of the root "index.html" file will be replaced with the result content of the request to the "/" URL path.

@jsakamoto
Copy link
Owner

@fingers10

And is there any other way we can avoid flickering effect when directly opening any routes other than index.html because index.html will have same content before and after blazor engine kicks in. For remaining pages index.html loads and then actual page loads.

The published results on usual Blazor WebAssembly apps with this NuGet package will behave without flickering, not as you reported.

I came up with two reasons for those flickering behavior.

  1. As I already said in the previous reply, it might be caused by PWA service workers.
    If that is true, your app will be unflickerly after fixing the "service-worker.published.js".

  2. The web server you used might not have the ability to fall back the request URL path to a rewritten URL that appended the ".html" file extension.
    If that is true, one of the solutions is don't set the BlazorWasmPrerenderingOutputStyle MSBuild property to AppendHtmlExtension when the project is publishing.
    Or, configuring the web server appropriately might also be one of the solutions.

@fingers10
Copy link
Contributor

@jsakamoto, is it possible for you to let me know your availability for a scheduled call?

@jsakamoto
Copy link
Owner

@fingers10

First of all, basically, please remember that this package is my hobby project using my free time, so I can't spend much time.

And, I'm a native Japanese speaker, not a native English speaker.
I can't speak and hear English fluently at all.
I often use machine translation a lot to read your post and write my reply.
I watched your technical session video via your post on LinkedIn, but unfortunately, I could not almost recognize what you said in English. (English subtitle of videos is helpful for me to understand what the speaker said.)

And, I live in Japan, so the time zone for me is Japan Standard Time, JST, UTC+9:00.

But I'm a little bit interested in your proposal even though some negative points are above.
Just curious, it is a little bit exciting for me talking with people who live over the sea because it is unusual for my life.

If you understand the above list well and still would like to make a scheduled call, would you like to send messages to me via the LinkedIn chatting window?
I'll try to make a time.

Of course, I don't mind changing your mind to cancel making a scheduled call for the above reasons.

@fingers10
Copy link
Contributor

@jsakamoto no worries. sorry to trouble you. we can connect once we get comfortable. till then lets discuss here. Coming to PWA reload. Do all the consumers of app needs to enable update on reload for this to take effect?

@jsakamoto
Copy link
Owner

@fingers10

Do all the consumers of app needs to enable update on reload for this to take effect?

No, all the consumers of apps usually do not need to enable the update on reload option.
The update on reload option is aimed at the app developer.

On the default implementation of the wwwroot/service-worker.published.js, the browser's "Reload" button (or Ctrl+R / F5 / Ctrl + F5 keyboard shortcuts) won't affect refreshing PWA offline apps.

Instead, once all browser processes are exited, or all browser's tabs navigated away from the app, the PWA app will be refreshed automatically next time access.
There is no needed press the browser's "Reload" button, Ctrl+R, or so on.

The Microsoft Docs site at the following link must be helpful for you.

Again, that behavior depends on the default implementation of the wwwroot/service-worker.published.js.

We should be able to control the cache behavior of PWA apps, such as choosing cache strategies, but I'm not familiar with it at this time.

About this topic, to ask in the "Stack Overflow" site might be a better way than to discuss in this issue thread.

@fingers10
Copy link
Contributor

fingers10 commented Jun 18, 2022

Hi @jsakamoto Publish fails after upgrading Microsoft.AspNetCore.Components.WebAssembly and Microsoft.AspNetCore.Components.WebAssembly.DevServer to 6.0.6.

I just updated all Nuget packages and Visual Studio to latest version. And on publish I get the following error.

C:\Program Files\dotnet\sdk\6.0.301\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Mi
crosoft.NET.Sdk.BlazorWebAssembly.6_0.targets(614,5): error MSB6006: "C:\Program Files
dotnet" exited with code 1. [C:\Users\User\source\repos\ilovedotnet\Web\Web.csp
roj]

@jsakamoto
Copy link
Owner

@fingers10
I could not reproduce the error that you said.😥
I upgraded Microsoft.AspNetCore.Components.WebAssembly and Microsoft.AspNetCore.Components.WebAssembly.DevServer to 6.0.6 on my some Blazor WebAssembly app projects and re-published them, but all of them resulted in success.

Please attach the project that you could reproduce this problem.
Please remember that most of the time for resolving an issue is spent reproducing the problem behavior.
If you attached the project that can reproduce the problem, I could get started to improve or fix this package immediately.

Thank you for your great cooperation! 👍

@fingers10
Copy link
Contributor

@jsakamoto I'm sorry. This looks like a dotnet sdk issue. There is an active issue in dotnet sdk repo for this.

@fingers10
Copy link
Contributor

fingers10 commented Jun 30, 2022

@jsakamoto , I would like to understand more on flickering effect that occurs when prerendered site is loaded. Please can you assist me on this.

I have this repo - https://github.com/fingers10/WasmServerPrerender published to GitHub Pages using the below URL.

Here is the sample URL that I'm using for testing - https://fingers10.github.io/WasmServerPrerender/fetchdata

Steps I followed,

  1. When I load in incognito window in chrome - The flickering effect is minimal. Only Data Shown in the screen is flickering. This is fine.
  2. When I load in normal window in chrome - index.html in wwwroot loads and the actual page loads. Is this the expected behavior?
  3. When I reload in both normal and in incognito window in chrome - index.html in wwwroot loads and the actual page loads. Is this the expected behavior?

Here is the video showing the same.

ScreenRecorderProject6.mp4

Thank you for your support and teaching.

@jsakamoto
Copy link
Owner

jsakamoto commented Jul 2, 2022

@fingers10 Thank you for informing me about that behavior with the very understandable report! I immediately understood this problem due to your detailed description and a short video.👍

Anyway, as far as I can see, that behavior you reported is not an expected one for me. It looks very weird.

Unfortunately, I don't have enough time to investigate this issue right now, but I'll do it later as soon as I have enough time.
(I'm not sure, but this weird behavior might involve a service worker.)

By the way, this issue #2 thread is unsuitable for discussing your reported issue. So I created new issue #17.
If I have any progress, I'll report it in the issue #17 thread.

@ElderJames
Copy link
Author

Sorry, I've been trying to use Prerendering build again recently and have failed. This is my branch that has solved the problem you mentioned above.

https://github.com/ant-design-blazor/ant-design-blazor/tree/chore/prerender-build

@jsakamoto
Copy link
Owner

@ElderJames Thank you for getting touch with me.
I'll look into that later.

@jsakamoto
Copy link
Owner

@ElderJames I sent a pull request to make the "AntDesign.Docs.Wasm" be able to pre-render with the "BlazorWasmPreRendering.Build" NuGet package.

@ElderJames
Copy link
Author

@jsakamoto Thank you for your generous help! I'll keep working to get it deployed online.

@fingers10
Copy link
Contributor

@jsakamoto whenever I publish and prerender and host in my local IIS, i get the following error

Uncaught SyntaxError: Unexpected token '<' (at decode.min.js:1:1)
brotliloader.min.js:1 Uncaught SyntaxError: Unexpected token '<' (at brotliloader.min.js:1:1)

image

On clicking of any of the above error, it takes me to respective js files and shows index.html content

image

I tried copy pasting the html to online html formatter but no errors or unexpected token. Please can you assist on this?

@jsakamoto
Copy link
Owner

@fingers10

Q1. Have you installed the PublishSPAforGitHubPages.Build NuGet package into your project?
Q2. Have you ever tried that publish again after completely deleting the bin and obj folders?
Q3. Are the brotliloader.min.js and decode.min.js files in the same folder where the index.html file is placed on your local IIS server?
Q4. Is the Blazor App you've deployed to your local IIS an offline-supported PWA?

@fingers10
Copy link
Contributor

@jsakamoto

Q1. Have you installed the PublishSPAforGitHubPages.Build NuGet package into your project? - Yes

image

Q2. Have you ever tried that publish again after completely deleting the bin and obj folders? - Yes

Q3. Are the brotliloader.min.js and decode.min.js files in the same folder where the index.html file is placed on your local IIS server? - No. I'm not able to find the brotliloader.min.js and decode.min.js in the publish output

image

Q4. Is the Blazor App you've deployed to your local IIS an offline-supported PWA? - No

@jsakamoto
Copy link
Owner

@fingers10

Thank you for your reply.
First of all, and as a basic premise, the reason for that problem is not the "BlazorWasmPreRendering.Build" package.
Who rewrites the index.html of your app to make the index.html will load brotliloader.min.js and decode.min.js files is the "PublishSPAforGitHubPages.Build" package. The "PublishSPAforGitHubPages.Build" package will also write out brotliloader.min.js and decode.min.js files to the target folder of publish.

Even if the "PublishSPAforGitHubPages.Build" package worked unexpectedly, it is still very weird that brotliloader.min.js and decode.min.js files do not exist in the IIS target folder, even though the index.html seems to be rewritten to load those files.

So, please respond to the following request from me.

  • Please attach the index.html in the source folder of your app to this thread.
  • Please attach the index.html in the target folder of your IIS server to this thread.
  • Please tell me detailed and complete how you published the app to the IIS server.
  • If you published the app via Visual Studio GUI, please attach the Properties/*.pubxml in the source folder of your app to this thread.
  • If you published the app via .NET CLI such as dotnet publish ~, please tell me exactly what command you did.
  • If you did not publish the app to the IIS server directly, there must exist the publish target folder in your PC disk locally, I guess. If so, please attach the index.html in the publish target folder to this thread. And try to publish again after deleting all files completely, not only the obj and bin folders but also the publish target folder.

@fingers10
Copy link
Contributor

@jsakamoto

  • Please attach the index.html in the source folder of your app to this thread. - src/wwwroot/index.html
  • Please attach the index.html in the target folder of your IIS server to this thread. - Attached
  • Please tell me detailed and complete how you published the app to the IIS server.
  • If you published the app via Visual Studio GUI, please attach the Properties/*.pubxml in the source folder of your app to this thread. - Attached
  • If you published the app via .NET CLI such as dotnet publish ~, please tell me exactly what command you did. - Not Applicable
  • If you did not publish the app to the IIS server directly, there must exist the publish target folder in your PC disk locally, I guess. If so, please attach the index.html in the publish target folder to this thread. And try to publish again after deleting all files completely, not only the obj and bin folders but also the publish target folder. - Attached

I published to default folder profile and copied the published contents to folder in C drive which is mapped to IIS virtual directory. I have attached the folder profile and publish contents.

Source Repository Used

Publish Output is more than 25MB and GitHub is not allowing to upload. hence giving you an external link to download. - https://www.mediafire.com/file/23hkiafkfaermnc/Publish+Issue.zip/file

@jsakamoto
Copy link
Owner

@fingers10 Thank you for providing detailed information. So I could figure out what is the reason for this problem.
It is the bug of the "PublishSPAforGitHubPages.Build" package.
The part of that package worked unexpectedly when the <GHPagesBase> MSBuild property was specified.
The workaround at this time is to comment out the specification of the <GHPagesBase> MSBuild property in your .csproj file temporary only when you publish the app for IIS.

Of couse, I'll fix the "PublishSPAforGitHubPages.Build" package. Please give me time for a while.

Again, Thank you for providing specific and detailed information. 👍

@jsakamoto
Copy link
Owner

@fingers10
I published the fixed version of the "PublishSPAforGitHubPages.Build" NuGet package ver.2.0.2.

Please upgrade to it and try that again.

Aside
if you still have any problem involved with the "BlazorWasmPreRendering.Build" NuGet package, please create a new issue thread and report into it. DON'T POST any topics into this thread anymore. This thread is already too late to track each discussion effectively because YOU pushed various topics into this thread! I'm really bothered by this long issue thread 😥. Don't hesitate to open a new thread. Try to create one Issue per happening.

However, I really appreciate you ❤️ because you always let me know if the packages I created seem to have a bug. Your activity must be helpful not only to me but also to all developers who use those my NuGet packages. So I'll thanks to you if you also understand how to treat GitHub issues!

@fingers10
Copy link
Contributor

@jsakamoto .

Many thanks for the fix. It's working now. I apologize for posting the issue here, I'll make sure I'll not repeat this next time.

@jsakamoto
Copy link
Owner

@fingers10

It's working now.

I'm happy for you that I heard about that from you! 😊 Again, many thanks to your contributions! 👍

@ElderJames
Copy link
Author

The prerendering have been available on antblazor.com ! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants