Search code examples
c#macosvisual-studioblazorvisual-studio-mac

Missing Blazor WebAssembly app template for Visual Studio for Mac


I am trying to create a Blazor WebAssembly app using the latest build of Visual Studio for Mac (v8.4.6 build 36).

I have .NET Core 3.1 SDK installed.

I also installed the latest Blazor WebAssembly 3.2.0 Preview 1 by running:

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.2.0-preview1.20073.1.

The output log shows it installed successfully:

Templates                                         Short Name               Language          Tags                                 
----------------------------------------------------------------------------------------------------------------------------------
Blazor Server App                                 blazorserver             [C#]              Web/Blazor                           
Blazor WebAssembly App                            blazorwasm               [C#]              Web/Blazor/WebAssembly

However, the Blazor WebAssembly App template does not show up in Visual Studio for Mac, even after restarting:

enter image description here And if I create a Blazor WebAssembly app from the CLI as follows, it builds but does not run:

dotnet new blazorwasm
dotnet build
dotnet run

And if I try to run it in Visual Studio for Mac I get this error: Cannot open assembly '/Users/my.username/projects/blazor/BlazerWasm/bin/Debug/netstandard2.1/BlazerWasm.exe': No such file or directory.

Is Visual Studio for Mac not able to build or run Blazor WebAssembly apps, or am I missing something?


Solution

  • **

    Microsoft has released a fix for this issue!

    **

    Support for Blazor WebAssembly projects has been added in the 8.6 release of Visual Studio for Mac. You can update by installing the latest from https://visualstudio.com/mac or updating to the Stable channel using the Visual Studio > Check for Updates… menu.

    Ultimately this update worked. However when trying to run the Blazor WebAssembly the very first time I got the following error:

    The ASP.NET Core developer certificate is in an invalid state. To fix this issue, run the following commands to remove all existing ASP.NET Core development certificates and create a new untrusted developer certificate.

    dotnet dev-certs https --clean
    dotnet dev-certs https
    dotnet dev-certs https --trust
    

    I followed the instructions running the three commands above and that resolved my error. FYI, the first of the three commands may take a few minutes and you may not see any output activity immediately.

    Now I can build a run Blazor WebAssembly in Version 8.6 of Visual Studio for Mac.

    For more info see the post I created in the Visual Studio Developer Community: