13

Today I updated Visual Studio to 17.4.0 Preview 2.1.

Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.4.0 Preview 2.1

After that, I can't deploy my Blazor application because I got this error:

To build this project, the following workloads must be installed: wasm-tools-net6 To install these workloads, run the following command: dotnet workload restore

I ran the command but nothing changed.

enter image description here

How can I fix it?

2
  • 1
    try "dotnet workload restore --interactive" Commented Dec 13, 2022 at 13:28
  • I tried this command and it installed NET7 but my application is in NET6 Commented Dec 13, 2022 at 18:42

5 Answers 5

8

I got this working by installing .NET WebAssembly Build Tools with the Visual Studio Installer:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Having done that, I still had to run "dotnet workload restore", then it worked.
4

This was hiding other errors for me.

Still, I was forced to install the correct NET workload to discover the real errors. In my case, I was targeting NET7, so I ran the following in the Package Manager Console (from the top menu: View > Other Windows > Package Manager Console):

dotnet workload install wasm-tools-net7

just change it to net6 if you target NET6.

After that, I still was seeing the same error: enter image description here

Then, I ran Clean and then Rebuild commands (right click solution -> Clean, then Rebuild Solution). After this last step, the real errors appeared:

enter image description here

Comments

2

I just ran into this problem as well after updating a few projects to .Net 7. I found that the problem related to the Target Framework, and Target Location of the publish profile. Once I upgraded these from .Net6 to .Net7 publishing worked again for me. enter image description here

1 Comment

you can run this command: dotnet workload install wasm-tools-net6
2

dotnet workload restore --interactive then restarting Visual Studio fixed it for me

Comments

0

For me (after trying all above answers and still having the same problem) it worked to untick the Ahead-of-time (AOT) compilation:

  1. From the main menu: Build -> Publish [myProject] -> Show all settings -> File Publish Options
  2. Untick Ahead-of-time (AOT) compilation

For me (after trying all above answers and still having the same problem) it worked to untick the Ahead-of-time (AOT) compilation:

  1. From the main menu: Build -> Publish [myProject] -> Show all settings -> File Publish Options
  2. Untick Ahead-of-time (AOT) compilation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.