jsakamoto / BlazorWasmPreRendering.Build

When you publish your Blazor Wasm app, this package pre-renders and saves the app as static HTML files in your public folder.
https://jsakamoto.github.io/BlazorWasmPreRendering.Build/
Mozilla Public License 2.0
245 stars 13 forks source link

Publish failed #2

Open ElderJames opened 3 years ago

ElderJames commented 3 years ago

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 commented 2 years ago

@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 commented 2 years ago

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

fingers10 commented 2 years ago

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

jsakamoto commented 2 years ago

@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 commented 1 year ago

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 commented 1 year ago

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

jsakamoto commented 1 year ago

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

ElderJames commented 1 year ago

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

fingers10 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

fingers10 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@fingers10

It's working now.

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