18

Trying to migrate from ASP.NET Core 3.1 to 5.0 using this guide provided by Microsoft.

Installed SDK 5.0.100-rc.1 with runtimes. Updated project as guide says and still getting following error:

There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'

Project file:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <UserSecretsId>*****</UserSecretsId>
    </PropertyGroup>
...

Cant find anything asociated with this error. I have no idea where to search for more info.

Thank you for any idea.

Panagiotis Kanavos
  • 90,087
  • 9
  • 138
  • 171
Kasta
  • 1,086
  • 1
  • 10
  • 22

8 Answers8

17

I finally made it work.

I did everything that guide said, except for the project file which I changed to this:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <UserSecretsId>*****</UserSecretsId>
    <UseBlazorWebAssembly>true</UseBlazorWebAssembly>
  </PropertyGroup>
...

But I have no idea if it is correct when official upgrade guide says to use:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

instead of:

<Project Sdk="Microsoft.NET.Sdk.Web">
Kasta
  • 1,086
  • 1
  • 10
  • 22
  • After changing my Project file as you say, and adding the `UseBlazorWebAssembly` as true, my client project builds, but then when I run its Server project, I get `Application startup exception: System.TypeLoadException: Method 'FilterDiagnostic' in type 'Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions' from assembly 'Microsoft.CodeAnalysis.CSharp, Version=3.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.` – Patrick Szalapski Sep 23 '20 at 15:51
  • I don't see anything in the [breaking changes](https://docs.microsoft.com/en-us/dotnet/core/compatibility/3.1-5.0) about `FilterDiagnostic` or `UseEndpoints`. – Patrick Szalapski Sep 23 '20 at 15:57
  • @PatrickSzalapski I am using Blazor Server so I have only one project in my solution. No idea how to help you. Try to focus on Richards answer below. – Kasta Sep 24 '20 at 07:14
  • Yep - same for me. – Sean Kearon Oct 28 '20 at 17:57
  • ditto=>same for me – Jazb Jan 12 '21 at 00:27
3

Had the same issue and finally got it working. Here's how.

In my case, the error wasn't the result of the Blazor project itself, but a referenced project in the same solution. The referenced project targets .net standard 2.1, which should be fine in itself; however, it also had some NuGet packages installed which might conflict with Blazor dependencies: (Microsoft.Extensions.*).

Solution
- Project A (.net standard 2.1 - Class library)
  - Dependencies
    - Packages
      - Microsoft.Extensions.Configuration.Json (<-- example dependency)
- Project B (.net 5 - Blazor webassembly)
  - Dependencies
    - Projects
      - Project A (<-- caused the error, presumably because of the above dependency)

The blog post about .net 5 rc mentions all Microsoft.Extensions.* packages in a Blazor project should be updated to 5.0.0-rc.1.*.

Was able to resolve the issue by removing the project dependency (which I didn't need in the first place, but accidentally got placed there).

What I don't understand is why a 'dotnet build' doesn't give an understandable error message about a conflict instead of this vague message about the runtime identifier mentioning the Blazor project.

Hope this will help others as well.

Richard
  • 280
  • 2
  • 8
  • 1
    Which extensions specifically? The Extensions used by Blazor Client are very different from the Extensions used by server-side ASP.NET Core. There shouldn't be any problems if ProjectA used the *abstractions* packages. – Panagiotis Kanavos Sep 23 '20 at 08:36
  • 1
    BTW .NET 5 doesn't use .NET Standard anymore to share code cross-platform. The .NET 5 target (`net5.0`)*is* the cross-platform target, with `net5.0-ios14.0` being the specific runtime. .NET Standard 2.1 is supported for compatibility but no longer used as *the* cross-platform target – Panagiotis Kanavos Sep 23 '20 at 08:41
  • I updated all four projects in my solution to `net5.0` but still get the same error. In your example, you thought that package Microsoft.Extensions.Configuration.Json was conflicting. Any idea how I might try to find what indirect dependencies of mine might be conflicting? – Patrick Szalapski Sep 23 '20 at 16:40
  • Honestly, not really. Guess I'd just try the old fashioned way by trial and error. (Create a new (empty) project with the same dependencies and reference that project from your blazor project. Then remove the dependencies one by one until the build succeeds. – Richard Sep 25 '20 at 14:02
  • I was trying to use Blazor WASM + gRPC server and when I added the gRPC service on Blazor project, I had this issue. To resolve this I follow this answer and remove the duplicated dependencies from the projects (Grpc.AspNetCore, added automatically on Blazor project), and everything worked. – cHida Nov 17 '20 at 02:27
3

I faced the same issue and asked Microsoft about that under this post: https://github.com/dotnet/aspnetcore/issues/27738

You need to update your projects to use below SDK's;

Client - Microsoft.NET.Sdk.BlazorWebAssembly
Server - Microsoft.NET.Sdk.Web
Shared - Microsoft.NET.Sdk
1

I had this issue with a different error message "The type or namespace name 'ApplicationPartAttribute' does not exist in the namespace 'Microsoft.AspNetCore.Mvc.ApplicationParts' (are you missing an assembly reference?)".

In my case I had a shared helper class library that I had started to build generic data api repositories into using Microsoft.AspNetCore.Mvc 2.0 which was referenced in my Blazor project using the newly released .Net 5.

To resolve this, I had to separate the shared class project moving the generic data api elements to a new project which removed the link between .Net 5 Blazor and Microsoft.AspNetCore.Mvc 2.0.

Sandy
  • 13
  • 3
1

Thanks for your help, In my case, I have to followup steps mentioned by @Kasta and official guide.

I make sure that below SDK changes are in place,Thank you @OzanYasinDogan for mentioning this helps.

  • Client - Microsoft.NET.Sdk.BlazorWebAssembly
  • Server - Microsoft.NET.Sdk.Web
  • Shared - Microsoft.NET.Sdk

In my case, I had to

  • Remove the <RuntimeIdentifier>browser-wasm</RuntimeIdentifier> and <UseBlazorWebAssembly>true</UseBlazorWebAssembly>. Mentioned here
  • Remove Microsoft.AspNetCore.Components.WebAssembly.BuildServer which was version 3.xx.xx causing conflicts from Blazor.Client Project file.
0

In my case I had referenced a project that was referencing Data layer classes and there for was not safe to for Blazor Client side or 'browser-wasm'.

After I removed the reference from Client solution > Dependencies > Projects My solution compiled.

KnuturO
  • 1,141
  • 11
  • 14
0

I experienced the same issue and discovered the cause to be

    <UseAppHost>true</UseAppHost>

which was used in a common Directory.Build.props

By setting this back to false I no longer get the missing browser-wasm error.

kolis
  • 176
  • 2
  • 9
-1

I resolved this issue in a way Richard described:

  1. Cleaned up references to Microsoft.Extensions.Logging, Microsoft.Extensions.Configuration,... packages version 3.2 in all solution projects referenced by server and client
  2. Updated .Server project
  3. Updated .Client project. Kept element at target framework section and it worked
<PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
stalskaper
  • 19
  • 1