azureblazor-webassembly

Error publishing Blazor Webassembly to Azure App Service. (netsdk1147: to build this project, the following workloads must be installed: wasm-tools)


When publishing blazor webassembly project to an azure app service, I get the following error "C:\Program Files\dotnet\sdk\7.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): Error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools To install these workloads, run the following command: dotnet workload restore".

I also checked use AOT and remove additional files at destination when publishing.

My API project publishes to the Azure App Service successfully, but not the blazor webassembly project.

I update my project via nuget. I use the latest version of visual studio (17.7.5).

The publish config is: Config: Release Target: .net 7.0 Mode: Self-contained Runtime: browser-wasm

I ran the dotnet workload restore from the command line successfully. Deleted the bin and obj folders. Deleted publish profile and added it again. Rebuild the solution. It still fails to publish. It used to publish a while back. Not sure why it no longer publishes to Azure.

I also tried unchecking AOT and get the same error plus the below error: obj\publish\browser-wasm\project.assets.json' not found. Run a NuGet package restore to generate this file.

I ran dotnet restore and the result was "All projects are up-to-date for restore."


Solution

  • I have deployed the Blazor WASM to Azure App Service without any issues.

    enter image description here

    enter image description here

    My .csproj file:

    <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    
      <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.12" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.12" PrivateAssets="all" />
      </ItemGroup>
    </Project>
    

    To build this project, the following workloads must be installed: wasm-tools

    Run dotnet workload install wasm-tools command in CLI /Package Manage Console.

    enter image description here

    OR Install by Modifying the VS Installer.

    enter image description here

    enter image description here