I am working on a Blazor web assembly project with multiple projects in a single solution. However, when I try to build the solution using dotnet build
, I get the following error:
error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.
Project structure (.sln
)
I have four projects in my solution:
RazorClassLibrary
(shared components)TraningBlazorAPIProject
(ASP.NET Core Web API)TraningBlazorProject
(Blazor server, acts as the main entry point)TraningBlazorProject.Client
(Blazor web assembly frontend)
TraningBlazorProject.Client.csproj
(Blazor web assembly):
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<ImplicitUsings>enable</ImplicitUsings>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
<Nullable>enable</Nullable>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.3" />
</ItemGroup>
</Project>
TraningBlazorProject.csproj
(Blazor server)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RazorClassLibrary\RazorClassLibrary.csproj" />
<ProjectReference Include="..\TraningBlazorProject.Client\TraningBlazorProject.Client.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.3" />
</ItemGroup>
</Project>
Error details
TraningBlazorProject.Client failed with 1 error(s)
C:\Program Files\dotnet\sdk\9.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(512,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.
Troubleshooting steps I tried (but didn't work):
Checked for
FrameworkReference
inTraningBlazorProject.Client.csproj
. Verified thatMicrosoft.AspNetCore.App
is not referenced in the web assembly project.Removed
ProjectReference
fromTraningBlazorProject.csproj
toTraningBlazorProject.Client.csproj
.Since Blazor web assembly should not be directly referenced by Blazor server, I temporarily removed it and tried building again, but the error persisted.
Reinstalled .NET workloads
Ran:dotnet workload uninstall wasm-tools dotnet workload install wasm-tools dotnet workload repair
But I'm still getting the same error.
Cleared NuGet caches and restored packages
dotnet nuget locals all --clear dotnet restore
Still no luck.
Deleted
bin
andobj
folders and rebuilt the projectrd /s /q bin obj dotnet clean dotnet restore dotnet build
The error remains.
Questions:
Why is Blazor web assembly (browser-wasm) trying to reference
Microsoft.AspNetCore.App
, which is only for Blazor server?Is there a conflict between
TraningBlazorProject.Client
(Blazor WASM) andTraningBlazorProject
(Blazor server)?How can I properly structure the solution to prevent this error?
I am working on a Blazor web assembly project with multiple projects in a single solution. However, when I try to build the solution using dotnet build
, I get the following error:
error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.
Project structure (.sln
)
I have four projects in my solution:
RazorClassLibrary
(shared components)TraningBlazorAPIProject
(ASP.NET Core Web API)TraningBlazorProject
(Blazor server, acts as the main entry point)TraningBlazorProject.Client
(Blazor web assembly frontend)
TraningBlazorProject.Client.csproj
(Blazor web assembly):
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<ImplicitUsings>enable</ImplicitUsings>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
<Nullable>enable</Nullable>
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.3" />
</ItemGroup>
</Project>
TraningBlazorProject.csproj
(Blazor server)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RazorClassLibrary\RazorClassLibrary.csproj" />
<ProjectReference Include="..\TraningBlazorProject.Client\TraningBlazorProject.Client.csproj" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.3" />
</ItemGroup>
</Project>
Error details
TraningBlazorProject.Client failed with 1 error(s)
C:\Program Files\dotnet\sdk\9.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(512,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'.
Troubleshooting steps I tried (but didn't work):
Checked for
FrameworkReference
inTraningBlazorProject.Client.csproj
. Verified thatMicrosoft.AspNetCore.App
is not referenced in the web assembly project.Removed
ProjectReference
fromTraningBlazorProject.csproj
toTraningBlazorProject.Client.csproj
.Since Blazor web assembly should not be directly referenced by Blazor server, I temporarily removed it and tried building again, but the error persisted.
Reinstalled .NET workloads
Ran:dotnet workload uninstall wasm-tools dotnet workload install wasm-tools dotnet workload repair
But I'm still getting the same error.
Cleared NuGet caches and restored packages
dotnet nuget locals all --clear dotnet restore
Still no luck.
Deleted
bin
andobj
folders and rebuilt the projectrd /s /q bin obj dotnet clean dotnet restore dotnet build
The error remains.
Questions:
Why is Blazor web assembly (browser-wasm) trying to reference
Microsoft.AspNetCore.App
, which is only for Blazor server?Is there a conflict between
TraningBlazorProject.Client
(Blazor WASM) andTraningBlazorProject
(Blazor server)?How can I properly structure the solution to prevent this error?
- I encountered this issue while working on a Blazor WebAssembly project. Initially, I created a new WebAssembly project and followed the steps carefully to identify the root cause of the error. After installing Newtonsoft.Json in the Client project, I started getting serialization errors. To debug, I systematically removed recent changes and found that the issue was directly related to Newtonsoft.Json. What I Discovered: Blazor WebAssembly is designed to work with System.Text.Json, which is the default JSON serializer in ASP.NET Core. – Mahdi Commented Mar 30 at 14:47
- I'm not very sure as I haven't test your scenario. I hope to know whether your app could work well when all of your projects are using .Net 7 and blazor server instead of blazor app. Based on what I know, we have blazor wasm with asp core host before .Net 8 and we will see an asp core web app references the blazor wasm app. But his mechanism was removed started from .Net 8. But I can see blazor wasm PackageReference in your server side app.. – Tiny Wang Commented Mar 31 at 3:15
1 Answer
Reset to default 1I had a test based on your description. Firstly, I created a blazor wasm stand alone application, and just like what you mentioned, if I added <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.3" />
, I will get the same error as you mentioned in question. This is because Microsoft.AspNetCore.Mvc.NewtonsoftJson
package is an ASP.NET Core-specific extension that integrates Newtonsoft.Json
into the MVC framework for server-side applications. Therefore, we can use <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
as a replacement. You can see differences between these 2 packages in this case.
Then I created a .Net 9 web app and a class library projects. I added blazor wasm project and class library project as reference into blazor web app. Then I get error
Conflicting assets with the same target path 'lib/bootstrap/dist/css/bootstrap-grid.min.css#[.{fingerprint=aexeepp0ev}]?.map.gz'. For assets 'Identity:xxxx
This is what I mentioned above, starting from .Net 8, there's no blazor web assembly with asp core hosted template. As a replacement, we have Blazor Web App. It provides the ability to add interactivity using either Blazor Server or Blazor WebAssembly on a per-component basis. In other words, you can both take advantage of blazor wasm and blazor server.