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-toolsdotnet workload install wasm-toolsdotnet workload repair
But I'm still getting the same error.
Cleared NuGet caches and restored packages
dotnet nuget locals all --cleardotnet restore
Still no luck.
Deleted
bin
andobj
folders and rebuilt the projectrd /s /q bin objdotnet cleandotnet restoredotnet 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?