Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Devops - Compatibility problems moving from .NET Core 3.1 to .NET 5 at Nuget Package

I have a .NET Core solution which was running well using .NET Core 3.1 using a Pipeline on Azure Devops. Everything was working fine on the Pipeline.

After moving from .NET Core 3.1 to .NET 5.0, I started to have some strange troubles running the pipeline, specifically with Nuget packages.

I can build with no problems, but when it starts to pack using Nuget Package, I've got this error:

[error] The nuget command failed with exit code(1)

NU1202: Package Microsoft.EntityFrameworkCore 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0). Package Microsoft.EntityFrameworkCore 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

Some weird fact is that this solution is running fine at the local machine.

<PropertyGroup>
  <TargetFramework>net5.0</TargetFramework>
  <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  <Version>1.8.8.9</Version>
  <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>

I already tried to change the OS on the Build, but I've got this error:

The current available version of MSBuild is 16.7.0.37604. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.

Does someone have an idea?

like image 557
Rafael Cronemberger Avatar asked Nov 15 '20 08:11

Rafael Cronemberger


People also ask

How do I add a NuGet package to Azure Devops artifacts?

Connect to feed Select Artifacts, and then select your feed from the dropdown menu. Select Connect to feed. Select NuGet.exe. Follow the instructions in Project setup to set up your nuget.

How do I add NuGet package to Azure pipeline?

Navigate to your classic pipeline definition, and then select Edit. Select + to add a new task. Search for NuGet, and then select Add to add the task to your pipeline. Name your task and select Restore from the Command.

What is NuGet in Azure Devops?

Put simply, a NuGet package is a single ZIP file with the . nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number.


1 Answers

Package Microsoft.EntityFrameworkCore.Relational 5.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

This is because it was using an old version of Nuget. You can try to change it to 5.x and restore.

enter image description here

Here is a case with similar issue you can refer to.

like image 139
Hugh Lin Avatar answered Oct 12 '22 05:10

Hugh Lin