3

I created a hosted WASM Blazor app using the Blazor client template in Visual Studio. I am trying to upgrade the Microsoft.AspNetCore.Components.WebAssembly package in the Client project from 3.2.1 to 5.0. I get this error:

Package Microsoft.AspNetCore.Components.WebAssembly 5.0.0 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1). Package Microsoft.AspNetCore.Components.WebAssembly 5.0.0 supports: net5.0 (.NETCoreApp,Version=v5.0) BlazorApp1.Client

The client project is targeting .NET Standard 2.1. I am not clear about the difference between targeting .NET standard and targeting .Net Core. I thought .NET Core 5.0 implements all of .NET Standard 2.1. Only .NET Standard target options are available.

How does one upgrade that package?

Also, there's no version 5.0 of Microsoft.AspNetCore.Components.WebAssembly.Build. Did the package get obsoleted?

Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374
  • Right-click the project, open properties, Go to the Application tab, change the Target Framework – Walter Verhoeven Nov 21 '20 at 07:45
  • 2
    https://learn.microsoft.com/en-us/aspnet/core/migration/31-to-50?view=aspnetcore-5.0&tabs=visual-studio#update-blazor-webassembly-and-blazor-server-projects – Brian Parker Nov 21 '20 at 07:46
  • @WalterVehoeven I SAID all the options are .NET standard and it's already targeting 2.1. – Tony_Henrich Nov 21 '20 at 08:00
  • If you were confused by VS's notification of possible package updates, try to switch to `dotnet outdated` which is more reliable, https://stackoverflow.com/a/64925213/11182 – Lex Li Nov 21 '20 at 08:01

1 Answers1

2

Although you can reference netstandard2.1 packages in a .NET5 application (targeting net5.0), to upgrade your Blazor app to 5.0.0 (.NET5) you also have to change target framework to net5.0 since it depends on it, as you have noticed.

But other than this, there are more changes to be made to get it fully upgraded. The MS Docs on how to Migrate from ASP.NET Core 3.1 to 5.0 (as Brian already pointed out) should help get the job done.

Michel Jansson
  • 1,803
  • 1
  • 13
  • 14
  • Does this apply to class libraries as well? I have a class library that has reference to this DLL and won't upgrade: https://github.com/Postlagerkarte/blazor-dragdrop/issues/94 – DoomerDGR8 Jan 26 '21 at 06:26
  • 1
    @HassanGulzar, correct. Remember - the purpose of .Net5 and forward is to consolidate .netcore and .netstandard to one cross-platform framework. And so, everything that is built now targets .net5. – Michel Jansson Feb 06 '21 at 16:07