0

Admittedly still very new to the DotNet core ecosystem.

I have a solution set-up with several class libraries for a framework I am porting over to DotNet core.

I have them targeting Core 2.1 (netcoreapp2.1).

I have Microsoft.EntityFrameworkCore package installed (v2.2) via NuGet.

Locally everything builds and runs fine.

The build definition (Azure DevOps) is failing because NuGet won't pull the EntityFrameworkCore package. Specifically:

Package Microsoft.EntityFrameworkCore 2.2.2 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.EntityFrameworkCore 2.2.2 supports: netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETCoreApp,Version=v2.1. 

The answer seems obvious - but I am confused on this. DotNet core supports NET Standard 2.0.

Also - I don't get this problem at all locally.

Making it even more confusing - the build actually succeeds if I ignore the NuGet error.

Is there something I need to be doing to make sure the projects explicitly state they are targeting netstandard2.0 in addition to a netcoreapp2.1?

Here is one of the offending project files.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
  <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ACME.Framework.Common\ACME.Framework.Common.csproj" />
  <ProjectReference Include="..\ACME.Framework.Entity\ACME.Framework.Entity.csproj" />
</ItemGroup>

</Project>

Update -

I upgraded to DotNet Core 2.2. Still getting this problem.

enter image description here

6
  • Can you post your purified .csproj?
    – Tubs
    Feb 25, 2019 at 15:25
  • posted one of the files.
    – JDBennett
    Feb 25, 2019 at 15:57
  • Have you run a dotnet restore/NuGet restore? I know it says in the documentation you don't need to but I've had to before. Our Azure DevOps runs the task prior to the build. May I ask why you've not upgraded to .NET Core 2.2? We've got tasks going through at the moment which are fine.
    – Tubs
    Feb 25, 2019 at 16:05
  • I have a nuget restore task in the build definition. That is where the error is occurring. When it pulls the EF package for one of the projects - I get the compatibility error. As far as the upgrade - I just got started on this task (porting). I will try that to see if we get a different result.
    – JDBennett
    Feb 25, 2019 at 16:12
  • 2
    If it's obvious, why not try then to downgrade Microsoft.EntityFrameworkCore to a lower version?
    – C.J.
    Feb 25, 2019 at 16:12

1 Answer 1

3

Got it figured out.

My build definition has 3 tasks (NuGet restore, DotNet build, MS Test).

The NuGet restore was failing. I was able to replicate it by downloading the same CLI version of NuGet that Azure Dev Ops was using (v4.1.0) as of today.

Running NuGet restore - I get the same error.

Changing the task to a dotnet restore eliminates this problem.

I would like to understand what dotnet restore is doing under the hood differently that NuGet is doing.

5
  • 1
    Ah that old chestnut. Yeah we've had to alternate between dotnet and nuget tasks. In order to create a NuGet package we had to use dotnet pack and to publish it to our vsix server we had to use the NuGet task.
    – Tubs
    Feb 25, 2019 at 17:09
  • 1
    The difference between dotnet restore and nuget restore is definitely the subject of another question here on stack overflow.
    – C.J.
    Feb 25, 2019 at 18:43
  • glad you got it figured out.
    – C.J.
    Feb 25, 2019 at 18:43
  • 1
    @Tubs good to know. I am just getting the deployment pipeline stood-up, so I am glad you told me that I need to switch between the tools ahead of time. Probably will save me a few hours of headache.
    – JDBennett
    Feb 25, 2019 at 19:23
  • No problem. It is certainly a fun one but the combination do work. We have internal NuGet and VSIX servers so we had to use all the combinations of the rainbow...
    – Tubs
    Feb 26, 2019 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.