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)
@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
@jsakamoto whenever I publish and prerender and host in my local IIS, i get the following error
On clicking of any of the above error, it takes me to respective js files and shows
index.html
contentI 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,
index.html
inwwwroot
loads and the actual page loads. Is this the expected behavior?index.html
inwwwroot
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
andMicrosoft.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
andMicrosoft.AspNetCore.Components.WebAssembly.DevServer
to6.0.6
.I just updated all Nuget packages and Visual Studio to latest version. And on publish I get the following error.
@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:
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:
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 inindex.html
once the blazor engine kiks in. But if we load any other page directly for example,www.jsakamoto.com/about
in this caseindex.html
content appears and once after blazor engine kicks in actualabout
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:
@fingers10
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.
Loading...
text in#app
element. Instead it’s appending with#app
element content.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.<head>
Tag, I noticed that a script tag is getting appeneded after all content inside<head>
Thanks for your response. This I resolved by adding
data
for script in my content security policy.index.hml
pages are not stored inside correct folder path. For example,Both the above urls get’s saved inside
blogs
folder asarticle-1.html
andarticle-2.html
but it has to be saved in the below structure. I have previously worked withreact-snap
which will prerender and follow the below structure.Thanks for your response. You understood the question correctly and your reading skills are good.
BlazorWasmPrerenderingOutputStyle
resolved the issue.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.
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,
the result of folders and files structure will be like below.
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
andhttps://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.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:
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
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.
Parsing of URL with fragment fails?
@jsakamoto This time I’m getting new error related to URI.
Console output:
I’ll develop a minimal repro sample and get back
@fingers10
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.
Error:
Stack Trace::
Error:
Stack Trace:
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?I’m guessing the error message
"The HTTP status code was not OK. (it was InternalServerError.)"
would be shown in the build process output.If so, you should be able also to see the prerendering command line text in the build process output.
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.
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.
I appreciate it if you report the details of the errors.
@jsakamoto still the same. No prerendering content in
index.html
after publishSure 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 inindex.html
. After changing to<body id="body" ..
publish succeeded. But here comes the new surprise. Theindex.html
has no prerendered content.Index.html
after publish:index.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:
Program.cs:
Index.razor.cs:
Error Logs:
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:
To:
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
inConfigureServices
. This fails with below error.Error:
Project Repo Link - https://github.com/fingers10/PrerenderTest
@fingers10
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:
Output log:
Project Repo Link - https://github.com/fingers10/BlazorWasmPreRenderGitDeploy
Please can you assist me on this?