1
votes

I have a solution with several .NET Standard 2.0, .NET Standard 2.1, .NET Core 3.0, and full .NET Framework 4.8 projects. The pipeline looks like this:

  pool:
    name: Azure Pipelines
    demands:
    - msbuild
    - visualstudio

  variables:
    BuildPlatform: 'any cpu'
    BuildConfiguration: 'release'

  steps:
  - task: UseDotNet@2
    displayName: 'Use .NET Core sdk 3.0'
    inputs:
      version: 3.0.100

  - task: DotNetCoreCLI@2
    displayName: 'dotnet restore'
    inputs:
      command: restore
      projects: '**/*.csproj'

  - task: NuGetToolInstaller@1
    displayName: 'Use NuGet 4.9.1'
    inputs:
      versionSpec: 4.9.1
      checkLatest: true

  - task: NuGetCommand@2
    displayName: 'NuGet restore'

  - task: VSBuild@1
    displayName: 'Build solution **\*.sln'
    inputs:
      vsVersion: 16.0
      platform: '$(BuildPlatform)'
      configuration: '$(BuildConfiguration)'
      clean: true

  - task: DotNetCoreCLI@2
    displayName: 'dotnet test'
    inputs:
      command: test
      projects: '**/*tests.csproj'

  - task: PublishSymbols@2
    displayName: 'Publish symbols path'
    inputs:
      PublishSymbols: false

After installing the correct SDK version, the pipeline runs dotnet restore to download all NuGet packages used by the .NET Standard and .NET Core projects. After that, it installs NuGet and uses it to restore the NuGet packages used by the full .NET Framework projects.

After migrating to .NET Core 3.0, however, the NuGet restore fails with the following error:

[error] The nuget command failed with exit code(1) and error(NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1)

NU1202: Package Microsoft.EntityFrameworkCore.Tools 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.Tools 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1) NU1202: Package Microsoft.EntityFrameworkCore.Relational 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.Relational 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1) Errors in d:\a\1\s\Pagesp.ChaveMovel.AspNetCore.Site.Identity.v2\Pagesp.ChaveMovel.AspNetCore.Site.Identity.v2.csproj NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1) NU1202: Package Microsoft.EntityFrameworkCore.Tools 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.Tools 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1) NU1202: Package Microsoft.EntityFrameworkCore.Relational 3.0.0 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.Relational 3.0.0 supports: netstandard2.1 (.NETStandard,Version=v2.1))

[error] Packages failed to restore

Any ideas on how to solve this?

1
When you run build locally do you use exacly the same version of packets (3.0.100 .net Core and EntityFrameworkCore 3.0.0 )? Did you try to run the pipeline without using "UseDotNet@2" task and without specyfing version of NugetTask?Kamil

1 Answers

7
votes

1) I managed to replicate your issue using:

  • Your pipeline
  • Sample project (source)

2) I commented out the versionSpec in the Nuget Task, after which the pipeline completed successfully:

- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 4.9.1'
  inputs:
    # versionSpec: 4.9.1
    checkLatest: true

3) The NuGet version that was automatically installed was 5.3.0