microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.49k stars 2.61k forks source link

error NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 5.0.0 is not compatible with net50 (.NETFramework,Version=v5.0) #14032

Closed Turochamp closed 3 years ago

Turochamp commented 3 years ago

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Docker

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

https://dev.azure.com/turochamp/TuroPhoto/_build?definitionId=4 https://dev.azure.com/turochamp/TuroPhoto/_build/results?buildId=24&view=results

Hosted Agent / Azure Pipeline

Issue Description

iBuild works fine on my local machine (Version 16.9.0 Preview 1.0), but on DevOps pipeline it reports:

Possibly significant difference is that local is using Nuget Package Manager 5.9.

Task logs

logs_28.zip

thesattiraju commented 3 years ago

@Turochamp the problem seems to be with .NET Core task. It's got nothing to do with Docker.

@bishal-pdMSFT could take a look

bishal-pdMSFT commented 3 years ago

@Turochamp it seems the .NET SDK being used in docker build is version 2.1.

2020-12-06T01:49:18.2381053Z Step 3/26 : FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build

I would suggest using .NET 5 sdk. Infact, I see that prior to docker build, there is a DotNetCoreCLI@2 task which uses .NET 5.0 and build is successful for that.

tiwarishub commented 3 years ago

Hi @Turochamp, Please let us know if it worked with .NET 5.0 sdk

BrachyN commented 3 years ago

I have the same issue. the build works fine in local machine but failed in the Azure DevOps pipeline with:

NU1202: Package Microsoft.EntityFrameworkCore 5.0.1 is not compatible with net50 (.NETFramework,Version=v5.0)

We don't use docker in this pipeline.

@tiwarishub, it does not work with SDK .NET 5.0 @Turochamp, Did you solve the issue? If so, can you please share how... ?.

BrachyN commented 3 years ago

The fix was to replace the package System.Data.SqlClient with Microsoft.Data.SqlClient and change nuget task in the build pipeline to 'dotnet restore' instead of 'Nuget restore' task. Thanks to my TL!

tiwarishub commented 3 years ago

Hi @BrachyN , thanks for suggestion. I think @Turochamp is already using Microsoft.Data.SqlClient package. And before his docker build , his build with task in which .net sdk version is 5 worked fine for him.

Hi @Turochamp , please let us know your results.

JimInNC commented 3 years ago

I'm having the save issue. I am not using System.Data.SqlClient. I am using Nuget 5.0. I am doing this through an Azure Devops Pipeline.

BrachyN commented 3 years ago

@JimInNC , Are you using the 'Nuget Restore' task or the 'dotnet restore' task in the Azure pipeline? if 'Nuget Restore' task, try disabling it and adding the 'dotnet restore' task. this was a solution in my case (also Azure pipeline)

JimInNC commented 3 years ago

Do you have the yml block to do that with?

tiwarishub commented 3 years ago

Hi @JimInNC , Can you please share your pipeline logs with system.debug to true and you tried with .NET 5 sdk right ?

Turochamp commented 3 years ago

Hi @bishal-pdMSFT and @tiwarishub I've tested changing the dockerbuild net sdk to 5 and it works.

The issue is now resolved. Thanks!