iisblazor-webassemblypublish

dotnet publish error WASM0005: Unable to resolve WebAssembly runtime pack version


I use dotnet publish to deploy a blazor webassembly hosted app to IIS:

location of server project> dotnet publish -c Release  -r win-x64 --self-contained false --output {AppDir}

But I get this error:

C:\Users\..\.nuget\packages\microsoft.net.sdk.webassembly.pack\8.0.0\build\Microsoft.NET.Sdk.WebAssembly.Browser.tar
gets(231,5): error WASM0005: Unable to resolve WebAssembly runtime pack version [C:\Users\..\Desktop\BlazorHosted\Bl
azorHosted\Client\BlazorHosted.Client.csproj]

How to correct this?

EDIT Since I get this error on a bigger .Net 8.0 project, I created a test webassembly hosted project with .Net 7.0, But I see inside package manager that webassembly.pack version is 8.0 while I created this project as 7.0, The error is the same:

enter image description here

EDIT2 I updated my visual studio 2022, with a newly created webassembly project, the error now happens for .net 8.0.2:

    C:\Users\..\Desktop\BlazorHosted3\BlazorHosted3\Server>dotnet publish
        -c Release  -r win-x64 --self-contained false
     MSBuild version 17.9.4+90725d08d for .NET   Determining projects to restore...   
    Restored C:\Users\..\Desktop\BlazorHosted3\BlazorHosted3\Client\BlazorHosted3.Client.csproj (in 1.66 sec).   
    2 of 3 projects are up-to-date for restore.  
     BlazorHosted3.Shared -> C:\Users\..\Desktop\BlazorHosted3\BlazorHosted3\Shared\bin\Release\net7.0\BlazorHosted3.Sh ared.dll 
    C:\Users\..\.nuget\packages\microsoft.net.sdk.webassembly.pack\8.0.2\build\Microsoft.NET.Sdk.WebAssembly.Browser.tar gets(231,5): 
error WASM0005: Unable to resolve WebAssembly runtime pack version [C:\Users\..\Desktop\BlazorHosted3\B lazorHosted3\Client\BlazorHosted3.Client.csproj]

in the mentioned (in error) file:

 <Target Name="_GetWasmRuntimePackVersion">
   <PropertyGroup>
     <_WasmRuntimePackVersion>%(ResolvedRuntimePack.NuGetPackageVersion)</_WasmRuntimePackVersion>
   </PropertyGroup>

   <Error Code="WASM0005" Text="Unable to resolve WebAssembly runtime pack version" Condition="'$(_WasmRuntimePackVersion)' == ''" />
 </Target>

Solution

  • I removed -c Release -r win-x64 --self-contained false and with this command:

    dotnet publish --output {AppDir}
    

    The publish is successful and without error.