最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Blazor WASM .NET 9 - NETSDK1082 Error: No runtime pack - Stack Overflow

programmeradmin1浏览0评论

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:

  1. RazorClassLibrary (shared components)
  2. TraningBlazorAPIProject (ASP.NET Core Web API)
  3. TraningBlazorProject (Blazor server, acts as the main entry point)
  4. 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):

  1. Checked for FrameworkReference in TraningBlazorProject.Client.csproj. Verified that Microsoft.AspNetCore.App is not referenced in the web assembly project.

  2. Removed ProjectReference from TraningBlazorProject.csproj to TraningBlazorProject.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.

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

  4. Cleared NuGet caches and restored packages

    dotnet nuget locals all --clear
    dotnet restore
    

    Still no luck.

  5. Deleted bin and obj folders and rebuilt the project

    rd /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) and TraningBlazorProject (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:

  1. RazorClassLibrary (shared components)
  2. TraningBlazorAPIProject (ASP.NET Core Web API)
  3. TraningBlazorProject (Blazor server, acts as the main entry point)
  4. 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):

  1. Checked for FrameworkReference in TraningBlazorProject.Client.csproj. Verified that Microsoft.AspNetCore.App is not referenced in the web assembly project.

  2. Removed ProjectReference from TraningBlazorProject.csproj to TraningBlazorProject.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.

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

  4. Cleared NuGet caches and restored packages

    dotnet nuget locals all --clear
    dotnet restore
    

    Still no luck.

  5. Deleted bin and obj folders and rebuilt the project

    rd /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) and TraningBlazorProject (Blazor server)?

  • How can I properly structure the solution to prevent this error?

Share Improve this question edited Mar 30 at 8:39 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 30 at 7:10 MahdiMahdi 238 bronze badges 2
  • 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
Add a comment  | 

1 Answer 1

Reset to default 1

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

发布评论

评论列表(0)

  1. 暂无评论