简体   繁体   中英

.NET 6 does not support .NET Standard 2.1?

I just updated a project from .NET 5 to .NET 6. It compiles and runs perfectly locally. When I push this to azure, running my CI pipeline, an error is reporting that:

NU1202: Package MyStandardPackaged 1.0 is not compatible with net60 (.NETFramework,Version=v6.0). Package MyStandardPackaged 1.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

Is there a workaround this, or I have to update this package declaring .NET 6?

If you look very carefully at the error message you posted:

NU1202: Package MyStandardPackaged 1.0 is not compatible with net60 (.NETFramework,Version=v6.0). Package MyStandardPackaged 1.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

Notice that it says that net6.0 is .NETFramework,Version=v6.0 . However, .NET 6 is actually .NETCoreApp,Version=v6.0 .

Therefore, I conclude you are using some old version of NuGet, that doesn't even know about .NET 5, to restore your project/solution.

My recommendation is to avoid the NuGetCommand task in Azure DevOps. Off the top of my head I can't think of any reason to use it, all the important features needed for a CI script exists in the dotnet CLI and MSBuild.exe .

Therefore, if all the projects in your solution/repo are SDK style (contain Sdk="whatever" in the project file), then use dotnet restore . If you have even a single non-SDK style project (every .cs in the directory is listed in the XML) then use msbuild -t:restore . This way, you'll never have a problem of mismatched NuGet versions again.

Simple answer: No

.NET Standard 2.1 is available for: .NET 5 or .NET Core 3. .NET Standard was developed and provided as a glue-technology between old .NET framwork and the new .NET Core framework. But .NET Core is already history. .NET 6 is currently the one and only .NET.

Source: https://docs.microsoft.com/en-us/dotnet/standard/net-standard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM