Blazor WebAssembly Shared UI Library
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Adding a project reference from a Blazor WebAssembly project to a Razor Class Library produces NETSDK1082 There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.
Expected Behavior
Use case: I wish to store my UI and logic in a shared class library that can be accessed by both a Blazor WASM app and a Blazor MAUI app, so I create a Razor Class Library to hold this logic.
I would expect that you would be able to reference a Razor Class Library from a Blazor WebAssembly application.
Steps To Reproduce
A demonstration solution is available here: https://github.com/Foxtrek64/BlazorSharedUI This solution contains three projects:
- A Maui Blazor app built from the default .NET 7 template, unmodified.
- A Razor Class Library. I’ve deleted the default Areas directory, added a Pages directory, and copied in the Index.razor file from the Blazor WebAssembly application.
- A Blazor WebAssembly application built with the Empty template, with Linux Docker support and PWA support.
Building the Blazor WebAssembly app and running it results in exactly what you might expect - the browser opens and shows Hello World as described by the default Index.razor file.
Steps to reproduce:
- Right click on BlazorSharedUI.Web -> Add -> Project Reference…
- Add a reference to BlazorSharedUI.Shared
- Click OK
- Run the app again. The NETSDK1082 exception is thrown at build.
The Maui Blazor app is not required for this demo, but I added it for completeness. Ideally, both of these projects would reference the .Shared library and pull their UI from there, but I can’t even get them to reference the library without catching on fire.
Exceptions (if any)
No response
.NET Version
7.0.100
Anything else?
There are many suggestions out there, such as #27738, suggest changing the project SDK of the shared project from Microsoft.NET.Sdk.Razor to Microsoft.NET.Sdk. Making this change simply produces a second error and has a tangential effect of no longer recognizing the wwwroot folder if one is present in the project (icon changes from a globe to the standard folder icon):
MSB4057 The target "RazorGenerateComponentDesignTime" does not exist in the project.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Thanks for contacting us. Looks like you’ve checked the
Support pages and viewsoption when you were creating the Razor Class Library project. Referencing these projects from a Blazor WebAssembly project is not supported. consider creating the project without that flag checked: https://github.com/Foxtrek64/BlazorSharedUI/blob/f98f2cce9b9413dc8e473df217492ba27c6f9c81/BlazorSharedUI.Shared/BlazorSharedUI.Shared.csproj#L7So to be clear - Is the current state of things that I can’t share a Page in an RCL library between wasm and server? I can share static content and components but not pages?