BlazorWasmPreRendering.Build: Publish failed

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.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 67 (35 by maintainers)

Most upvoted comments

@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 .

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.

@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!

@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 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 Thank you for your generous help! I’ll keep working to get it deployed online.

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 , 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.

https://user-images.githubusercontent.com/43729469/176577418-17ed84df-8dc9-4625-848f-12e15ba563c0.mp4

Thank you for your support and teaching.

@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! 👍

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]

@fingers10

If my memory is correct, your project is a PWA with offline support, right?

If so, that experience may be caused by a service worker’s script.

The default implementation of a service worker script created by standard ASP.NET Core project templates should be like this:

// This is "service-worker.published.js"
....
async function onFetch(event) {
  ...
  const shouldServeIndexHtml = event.request.mode === 'navigate';
  const request = shouldServeIndexHtml ? 'index.html' : event.request;
  ...

That default implementation will always return “index.html” forcibly whatever any URLs of requests as a fallback behavior.

Therefore, when you request the ULR path “/about”, the service worker script will return “index.html” even though the “about.html” exists.

To correct this behavior, please try to change the service worker script like this:

// This is "service-worker.published.js"
....
async function onFetch(event) {
  ...
  // 👇 change this line.
  const shouldServeIndexHtml = event.request.mode === 'navigate' && new URL(event.request.url).pathname === '/';
  const request = shouldServeIndexHtml ? 'index.html' : event.request;
  ...

I hope this information will be helpful for you.

@jsakamoto out of curiosity I’m asking. index.html without loading text is great. We have same content in index.html once the blazor engine kiks in. But if we load any other page directly for example, www.jsakamoto.com/about in this case index.html content appears and once after blazor engine kicks in actual about page appears. Is it a good user experience?

@jsakamoto that works. Now Loading Text doesn’t appear.

@fingers10

I released the fixed version v.1.0.0-preview.22.0 just now.

I appreciate it if you try it out. Again, I’d say many thanks for your contributions!

@fingers10 Thank you for the report!

The crawler maybe encountered a mailto:// link.

I’ll fix it, and moreover, I’ll consider once again how to traverse hyperlinks more carefully than before.

@jsakamoto, publish failed with the following message,

Console output:
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.70
Start fetching...[http://127.0.0.1:5050]
Getting http://127.0.0.1:5050/...
Getting http://127.0.0.1:5050/blogs/webapi-importance-of-status-code...
Getting http://127.0.0.1:5050/channels/webapi...
[WARNING] The requested URL (javascript: void(0)) was not navigatable.
Getting http://127.0.0.1:5050/blogs/blazor-wasm-exception-handling-and-error-boundary...
Getting http://127.0.0.1:5050/channels/blazor...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-app-settings...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-error-logging...
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-javascript-interop-and-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-javascript-interop-and-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-javascript-interop-and-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-javascript-interop-and-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-javascript-interop-and-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-styles-and-css-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-styles-and-css-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-styles-and-css-isolation...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-lazy-loading...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-lazy-loading...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-lazy-loading...
Getting http://127.0.0.1:5050/talks/blazor-spa-from-aspnet-family...
Getting http://127.0.0.1:5050/channels/talk...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-exception-handling-and-error-boundary...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-exception-handling-and-error-boundary...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-exception-handling-and-error-boundary...
Getting http://127.0.0.1:5050/blogs/blazor-wasm-error-logging/...
Getting http://127.0.0.1:5050/disclaimer...
Getting http://127.0.0.1:5050ab%64%75lrah%6Dan.s%6D%73%69@gm%61il%2Ec%6F%6D...
  [ERROR] The requested URL (http://127.0.0.1:5050ab%64%75lrah%6Dan.s%6D%73%69@gm%61il%2Ec%6F%6D) was not valid format.

INFORMATION
===========
The crawler encountered whatever errors.
If you want to keep running the pre-rendering server process for debugging it on live, you can do that by setting the "BlazorWasmPrerenderingKeepServer" MSBuild property to "true".

ex) dotnet publish -p:BlazorWasmPrerenderingKeepServer=true

Fetching complete.
C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.21.0\build\BlazorWasmPreRendering.Build.targets(55,5): Error MSB3073: The command "dotnet "C:\Users\Abdul Rahman\.nuget\packages\blazorwasmprerendering.build\1.0.0-preview.21.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\xxxx\Web\obj\Release\net6.0\browser-wasm\PubTmp\Out" -i "C:\Users\Abdul Rahman\source\repos\xxxx\Web\obj\Release\net6.0\." -m "Toolbelt.Blazor.HeadElement.ServerPrerendering,,6.0.2" -f "net6.0" --serviceworkerassetsmanifest "service-worker-assets.js" -e "Production" -o "IndexHtmlInSubFolders"  -d -u "/disclaimer"" exited with code 1.

5>Build failed. Check the Output window for more details.
========== Build: 4 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

@fingers10

But I think this needs to be considered because when the page gets listed in search result then it will show Loading... text.

Yes, that’s right.

So today, I provided the option that developers can choose whether keep the “Loading…” contents in prerendered output HTML files or not.

Please check the “BlazorWasmPreRendering.Build” version 1.0.0-preview.20.0 if you are interested in it.

You can see the detailed documents at the following link.

@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

Thanks for your response. But I think this needs to be considered because when the page gets listed in search result then it will show Loading... text.

  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>

Thanks for your response. This I resolved by adding data for script in my content security policy.

  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

Thanks for your response. You understood the question correctly and your reading skills are good. BlazorWasmPrerenderingOutputStyle resolved the issue.

  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.

Again thanks for the response.

Are you on Linkedin? is there any other ways to contact you other than GitHub? In case you wanna share contact details privately, you can drop a message to me on my Linkedin Profile.

@fingers10

Sorry too late! Thank you for waiting for my answer.

  1. I also noticed that the respective index.hml pages are not stored inside correct folder path.

I’m sorry, but I might not understand your question correctly due to my lack of reading skills. But anyway, I’ll try to explain it.

“dotnet publish” command targetting Blazor WebAssembly apps generates all of the static contents under the “wwwroot” folder inside of the target of publishing folder.

For example, if you executed the command targetting a Blazor WebAssembly project as below,

> dotnet publish -o:/foo/bar

the result of folders and files structure will be like below.

/foo
  /bar
    /wwwroot
      index.html

That is the standard behavior of ASP.NET Core projects, including Blazor WebbAssembly projects.

And, if that Blazor WebAssembly app has route URLs like https://example.com/blogs/article-1 and https://example.com/blogs/article-2, the “BlazorWasmPreRendering.Build” package will save them to static files the same way with ASP.NET Core’s standard folders and files structure, like this.

/foo
  /bar
    /wwwroot
      index.html
      /blogs
        /artice-1
          index.html
        /artice-2
          index.html

That behavior will be what almost ASP.NET Core Web application developers expect, I think.

P.S. If you specify the “BlazorWasmPrerenderingOutputStyle” MSBuild property option to “AppendHtmlExtension”, the published folders and files structure will be like this:

/foo
  /bar
    /wwwroot
      index.html
      /blogs
        artice-1.html
        artice-2.html

If your publishing result what you saw is different from my explanation above, please let me know with more details. In that case, that means the “BlazorWasmPreRendering.Build” package might have some software bugs, and I’ll fix them.

@jsakamoto , I think you missed to respond 3rd and 4th query in my original comment. Please can you assist?

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

@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.

@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 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

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.

@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.

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.

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

Sure I’ll check and get back.

@fingers10 I’m sorry I had mistaken too.

(see also the commit message of: 105bc7cacb5abb6910407efc076633b50927e973)

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

@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 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

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”.

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

@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

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

@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 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?