Package Microsoft.AspNetCore.Components.WebAssembly 5.0.0 is not compatible with netstandard2.1 (.NETStandard,Version=v2.1) - visual-studio-2019

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?

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.

Related

Visual studio 2019 doesn't show me .NET Standard 2.1 and .NET Core 3.1 as part of Target Framework. .NET Core 3.1 is installed on my system

Note: I use VS 2019 Professional
Version 16.0.2
Problem:
I have a source code base working perfectly fine in VS 2017. But to support .NET core 3.1, I have decided to upgrade my VS 2017 to VS 2019.
When I open-source code in VS 2019. It's not showing .NET Standard 2.1 and .NET Core 3.1 as part of Target Framework. When I look for project properties.
When I modify .csproj file with <TargetFramework>netcoreapp3.1</TargetFramework> and then build I get:
The current .NET SDK does not support targeting .NET Core 3.1. Either
target .NET Core 2.1 or lower, or use a version of the .NET SDK that
supports .NET Core 3.1.
For another project, When I modify the .csproj file with <TargetFramework>netstandard2.1</TargetFramework> and then build I get:
The current .NET SDK does not support targeting .NET Standard 2.1.
Either target .NET Standard 2.0 or lower, or use a version of the .NET
SDK that supports .NET Standard 2.1.
What I have tried:
Now I decided to create a brand new project in VS 2019. Then the
the surprising thing is it just shows me .NET Standard 2.1 and .NET Core 3.1 as part of Target Framework.
Also looking at the previous StackOverflow answers. I have created the global.json file at the top of my solution. global.json look like
{
"sdk": {
"version": "3.1.402"
}
}
but I as part of my solution. I have 2 projects. The first project is netstandard and the second project is netcore [my test project is netcore]. The test project allows me to select 3.1 from the project property target framework section but my first project is not able to show me netstandard2.1 as part of the project property target framework. Did my global.json is wrong?
Expectation:
My source code which is building perfectly on VS 2017 should have been building on VS 2019.
Answer to my question:
Update VS 2019 - I was using VS 2019 16.0.2 professional (by default triggered by IT). To solve my issue, I need to update VS 2019 to 16.4 because it includes .NET Core 3.1.
Update .sln file: I need to do this because my source code was developed using vs2017 that's why my .sln file was according to VS2017. VS 2019 will use MSBuild 16. Make sure .sln should have an entry for VisualStudioVersion = 16.. (To generate this you can create a dummy project application with VS2019 and then compare your project .sln file with the generated VS2019 .sln file you will see the difference)
NOTE: Also, make sure if you are using .NET Core 2.1 SDK then install v2.1.810 which is meant for VS2019.

Unable to install dapper 2.0.30 with .net framework 4.5

I am learning dapper ORM. While installing it through nuget package manager I am getting following error:
Could not install package 'Dapper 2.0.30'. You are trying to install
this package into a project that targets '.NETFramework,Version=v4.5',
but the package does not contain any assembly references or content
files that are compatible with that framework. For more information,
contact the package author.
In target framework option in project properties I've changed .net framework from 2.0 to 4.5.1
No 2.* (or above) version of Dapper supports .NET 4.5.*, and there are no plans to do so. You will have to update your target framework, or stick with older versions of the tool. Preferably the first.
Ultimately you should expect this to be more and more of a problem if you choose to use old frameworks.
Here's what I saw:
Dapper 1.60.1 needs .NET 4.5.1
Dapper 1.50.4 needs .NET 4.5.1
Dapper 1.50.2 needs .NET 4.0
Therefore, having .NET 4.5, I installed Dapper 1.50.2
dapper 2.0.30 of supports only .NET Framework 4.6.1 and .NET Standard 2.0
the max version that supports .NET Framework 4.5 is dapper 1.50.2
More informations can be found on the official nuget link: https://www.nuget.org/packages/Dapper/1.50.2#dependencies-tab

Does ASP.NET Core version have to match nuget package versions?

I'm trying to work out which version of the ASP.NET related packages I should be using.
We are trying to stick to LTS versions of ASP.NET Core, meaning we are still on version 2.1 and not 2.2 for the compiler and runtime. However I'm having a hard to trying to find out what version of the nuget packages we should be using.
for example, Microsoft.AspNetCore.Mvc says that its latest version is 2.2.0 and visual studio wants me to upgrade to this. However, I am wondering if we should stay on 2.1.3 since we are still on 2.1 for the compiler.
Are these version numbers related? Should we be staying back on 2.1.x to match pace with the compiler or are we doing things wrong?

Net standard Library missing reference in ASP.NET Boilerplate

every time i clone Abp.ModuleZero to my machine when i run nuget command update-database the error show me and when i build the solution in viusal studio the project doesn't build and show many errors in error list console window
most of them is like :
The type 'Object' is defined in an assembly that is not referenced.
You must add a reference to assembly 'netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
i try to install Netstandard.library package from package manager console window but doesn't any sense.
my visual studio IDE version is 2015 Update 3.
ABP v3.0.0 is based on .NET Standard 2.0.
This concerns you regardless if you are on MVC 5.x, .NET Framework 4.x or .NET Core 2.x.
You should use VS2017 15.3.3+.
For VS2015, you may try installing NuGet client 3.6 or higher but that may no longer work.
i think downgrade to earlier version of this framework is good solution for me, where can i download early version of ABP framework like 2.3.4?
I don't see why you would download the framework, but it's on GitHub.
If you meant download a template that uses an earlier version of ABP:
You can only choose the project version for premium startup templates.
You can build your own from module-zero-core-template/releases/tag/v2.5.1.
You need to rename the files and folders yourself.

After installing microsoft.aspnet.core through nuget, all my packages got NU1002 error, what's wrong?

At first, I built up a ASP.NET5/MVC6 project with .netcore in VS2015 community, everything was OK. With going deeper and deeper. I have to use session or tempdata, but after I add microsoft.netcore.session package, package restore will fail and all my existing package got NU1002 error said: NU1002 the dependency XXXX in project XXXX does not support framework DNX, version=v4.5.1. Like the picture.
Error on all packages
But if I uninstall the session package, eveything is OK. What's wrong with this ? My sdk version in global.json is 1.0.0-rc1-update1 and I have removed DNX5.0 from project.json. Does anyone could help me?
According to your screenshot you are using DNX framework in your project, which should be the old version ASP.NET 5 project framework. After ASP.NET 5 upgrade to .NET Core, the framework is now called .NETCoreApp. And the SDK version now is 1.0.0-preview2-003121. The error message also means the dependency does not support framework DNX. I have installed the Microsoft.AspNetCore.Session package successful in my Visual Studio 2015 with latest .NET Core SDK version.
So I suggest you download the latest .NET Core SDK installer from below link and then create a new .NET Core application and then move your original project files to the new project and then install the session package.
https://www.microsoft.com/net/download
If your project is create by ASP.NET 5 RC1 project template, please refer to following article to migrate it to ASP.NET Core 1.0.
https://docs.asp.net/en/latest/migration/rc1-to-rtm.html

Resources