0
votes

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

2
I still have this problem. as suggested in you link, I tried using .NET Restore instead of NuGet Restore. Still similar errors C:\Program Files\dotnet\sdk\2.1.806\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.Vinny

2 Answers

0
votes

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'
0
votes

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.