Vinny
Vinny

Reputation: 619

Azure DevOps Pipeline failing at NuGet restore task

I created a Azure function Project in Visual studio 2019. Everything works great on my desktop but the project is failing at NuGet Restore task in Azure DevOps Pipeline with below error.

Package Microsoft.Azure.WebJobs 3.0.0 is not compatible with netcoreapp3.1

2020-06-09T08:32:02.2578449Z ##[error]The nuget command failed with exit code(1) and error(Errors in E:\agent_work\491\s\CPUSRETools\AzureCapacityUsage\AzureCapacityUsage.csproj Package Microsoft.Azure.WebJobs 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.Azure.WebJobs.Extensions 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs.Extensions 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.Azure.WebJobs.Extensions.Http 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs.Extensions.Http 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETCoreApp,Version=v3.1.)

2020-06-09T08:32:02.2592475Z ##[debug]Processed: ##vso[task.issue type=error;]The nuget command failed with exit code(1) and error(Errors in E:\agent_work\491\s\CPUSRETools\AzureCapacityUsage\AzureCapacityUsage.csproj%0D%0A Package Microsoft.Azure.WebJobs 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)%0D%0A Package Microsoft.Azure.WebJobs.Extensions 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs.Extensions 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)%0D%0A Package Microsoft.Azure.WebJobs.Extensions.Http 3.0.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.Azure.WebJobs.Extensions.Http 3.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)%0D%0A One or more packages are incompatible with .NETCoreApp,Version=v3.1.)

2020-06-09T08:32:02.2594955Z ##[debug]task result: Failed

2020-06-09T08:32:02.2595537Z ##[error]Packages failed to restore

Upvotes: 0

Views: 11146

Answers (2)

Vinny
Vinny

Reputation: 619

I managed to find a work around for my issue. I have 9 Projects that I getting built fine using VSBuild Task. One project is failing to build in VSBuild Task. So I moved that task to a new Solution. Pointed the VSBuild to old Solution which has 9 projects and Pointed the .NET Build Task to new Solution file which was failing in VSBuild.

Now world is colorful again.

Upvotes: 0

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30313

It showed from the error that the dotnet task was using version 2.1.806 dotnet sdk. But your project is targeting dotnet 3.1.

You can use task Use .Net Core to use the specific version .Net Core (version 3.1) in your pipeline. See below

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
  inputs:
    packageType: sdk
    version: 3.x

- task: DotNetCoreCLI@2
    inputs:
      command: restore
      projects: '**\*.csproj'

Upvotes: 1

Related Questions