Reputation: 11389
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?
Upvotes: 17
Views: 18310
Reputation: 14981
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.
Upvotes: 28