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

Error on .net9 rc2, Ubuntu 22 #47

Open
felixf4xu opened this issue Nov 8, 2024 · 7 comments
Open

Error on .net9 rc2, Ubuntu 22 #47

felixf4xu opened this issue Nov 8, 2024 · 7 comments

Comments

@felixf4xu
Copy link

Hi,

I'm testing blazorwasm in Ubuntu 22, with commands as below:

dotnet new blazorwasm -o WasmApp
cd WasmApp/
dotnet add package BlazorWasmPreRendering.Build
dotnet publish

then I have this error:

WasmApp failed with 1 error(s) (11.1s) → bin/Release/net9.0/publish/
/home/cc/.nuget/packages/blazorwasmprerendering.build/4.0.1/build/BlazorWasmPreRendering.Build.targets(64,5): error MSB3073: The command ""/home/cc/dotnet/dotnet" "/home/cc/.nuget/packages/blazorwasmprerendering.build/4.0.1/build/../tools//BlazorWasmPreRendering.Build.dll" --assemblyname "WasmApp" -t "WasmApp.App" --selectorofrootcomponent "#app,app" --selectorofheadoutletcomponent "head::after" -p "/home/cc/testcode/WasmApp/bin/Release/net9.0/publish" -i "/home/cc/testcode/WasmApp/obj/Release/net9.0/." --assemblydir "/home/cc/testcode/WasmApp/bin/Release/net9.0" -m "" -f "" --serviceworkerassetsmanifest "" --environment "Prerendering" --emulateauthme "true" --locale "en" -o "IndexHtmlInSubFolders" -u "" -r "Static" --serverport "5050-5999" --bwapoptionsdllext "bin"" exited with code 1.

@jsakamoto
Copy link
Owner

Hi @felixf4xu,

Could you try to use the version 5.0 preview 2? You can update your project by following the command:

dotnet add package BlazorWasmPreRendering.Build --version 5.0.0-preview.2

Since the .NET 9 SDK has not been officially released yet, I've kept the latest version of the "BlazorWasmPreRendering" package as a preview release.

@axiom-nz
Copy link

axiom-nz commented Jan 1, 2025

I'm getting this same error on a standalone WASM project on .net 9. I'm running the latest release of this package.

/Users/user/.nuget/packages/blazorwasmprerendering.build/5.0.0/build/BlazorWasmPreRendering.Build.targets(65,5): error MSB3073: 
The command ""/usr/local/share/dotnet/dotnet" "/Users/user/.nuget/packages/blazorwasmprerendering.build/5.0.0/build/../tools/net9.0/BlazorWasmPreRendering.Build.dll" 
    --assemblyname "Portal.WASM" -t "Portal.WASM.App" --selectorofrootcomponent "#app,app" 
    --selectorofheadoutletcomponent "head::after" -p "/Users/user/Projects/Blazor/Portal.WASM/bin/Release/net9.0/publish" 
    -i "/Users/user/Projects/Blazor/Portal.WASM/obj/Release/net9.0/." --assemblydir "/Users/user/Projects/Blazor/Portal.WASM/bin/Release/net9.0" 
    -m "" -f "net9.0" --serviceworkerassetsmanifest "service-worker-assets.js" --environment "Prerendering" 
    --emulateauthme "true" --locale "en" -o "IndexHtmlInSubFolders"  -u "" -r "Static" --serverport "5050-5999" --bwapoptionsdllext "bin"" 
exited with code 1.

@jsakamoto
Copy link
Owner

@axiom-nz Could you show me the entire of your build log? The root causing error message must be there.

@axiom-nz
Copy link

axiom-nz commented Jan 1, 2025

This is the full build log.

❯ dotnet publish
Restore complete (0.4s)
  Models succeeded with 3 warning(s) (0.1s) → Models/bin/Release/net9.0/publish/
    /Users/user/Projects/Blazor/Models/Internal/StoreDetails/Store.cs(5,19): warning CS8618: Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /Users/user/Projects/Blazor/Models/Internal/StoreDetails/Store.cs(6,19): warning CS8618: Non-nullable property 'WebsiteUrl' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
    /Users/user/Projects/Blazor/Models/Internal/StoreDetails/Store.cs(7,19): warning CS8618: Non-nullable property 'ApiUrl' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
  Services succeeded with 1 warning(s) (0.3s) → Services/bin/Release/net9.0/publish/
    /Users/user/Projects/Blazor/Services/Provider.cs(51,26): warning CS0168: The variable 'e' is declared but never used
  Portal.WASM failed with 1 error(s) and 4 warning(s) (13.3s) → Portal.WASM/bin/Release/net9.0/publish/
    /Users/user/Projects/Blazor/Portal.WASM/Layout/MainLayout.razor(45,23): warning CS8601: Possible null reference assignment.
    /Users/user/Projects/Blazor/Portal.WASM/Pages/StoreSearchResults.razor(16,81): warning CS8602: Dereference of a possibly null reference.
    /Users/user/Projects/Blazor/Portal.WASM/Pages/Home.razor(61,55): warning CS8602: Dereference of a possibly null reference.
    /Users/user/Projects/Blazor/Portal.WASM/Pages/Home.razor(62,54): warning CS8602: Dereference of a possibly null reference.
    /Users/user/.nuget/packages/blazorwasmprerendering.build/5.0.0/build/BlazorWasmPreRendering.Build.targets(65,5): error MSB3073: The command ""/usr/local/share/dotnet/dotnet" "/Users/user/.nuget/packages/blazorwasmprerendering.build/5.0.0/build/../tools/net9.0/BlazorWasmPreRendering.Build.dll" --assemblyname "Portal.WASM" -t "Portal.WASM.App" --selectorofrootcomponent "#app,app" --selectorofheadoutletcomponent "head::after" -p "/Users/user/Projects/Blazor/Portal.WASM/bin/Release/net9.0/publish" -i "/Users/user/Projects/Blazor/Portal.WASM/obj/Release/net9.0/." --assemblydir "/Users/user/Projects/Blazor/Portal.WASM/bin/Release/net9.0" -m "" -f "net9.0" --serviceworkerassetsmanifest "service-worker-assets.js" --environment "Prerendering" --emulateauthme "true" --locale "en" -o "IndexHtmlInSubFolders"  -u "" -r "Static" --serverport "5050-5999" --bwapoptionsdllext "bin"" exited with code 1.

@jsakamoto
Copy link
Owner

@axiom-nz Hum... it is not usual. Could you share your project with me? I have to investigate why the build error happens on my side.

@axiom-nz
Copy link

axiom-nz commented Jan 2, 2025

Sorry I'm unable to share the repo. I kicked off a build with the BlazorWasmPrerenderingKeepServer flag set to true and hit localhost:5050. With this stacktrace the issue became pretty clear. I wrapped the SessionStorage code in OnInitializedAsync in a try-catch and reran the publish. It worked as expected! Thanks for the prompt response @jsakamoto.

I'll have a play around with moving this to OnAfterRenderAsync, though if that results in a flicker for users I might just leave it as is.

I'm assuming an exception is bubbling up for @felixf4xu as well.

System.InvalidOperationException: IJSInProcessRuntime not available
   at Blazored.SessionStorage.BrowserStorageProvider.CheckForInProcessRuntime()
   at Blazored.SessionStorage.BrowserStorageProvider.ContainKey(String key)
   at Blazored.SessionStorage.SessionStorageService.ContainKey(String key)
   at Portal.WASM.Pages.Home.OnInitializedAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

@jsakamoto
Copy link
Owner

Hi @felixf4xu,
As you probably know, the BlazorWasmPreRendering.Build package ver.5.0.0 has been released, and it officially supports .NET 9 SDK. Have you tried it yet?

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