Home > Software design >  ADO Pipeline - Restore Packages for DotNet 6
ADO Pipeline - Restore Packages for DotNet 6

Time:12-11

I have a dotnet solution containing test and library projects an Azure Functions project.

I've updated all nuget packages to the latest versions and set the Azure Functions project to

<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>

In VS2022 everything now builds ok and all the tests pass.

However, when my Azure DevOps build pipeline runs its nuget restore task, I get lots of errors about various package incompatibility with net60 such as:

Package Serilog.Extensions.Hosting 4.1.2 is not compatible with net60 (.NETFramework,Version=v6.0).

The yaml for the restore task of the build pipeline is:

- task: NuGetCommand@2
  displayName: Restore
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'

The build pipeline is set to run with:

jobs:
job: Build
displayName: Build
pool:
  vmImage: 'windows-latest'

Anyone explain why the solution would restore and build ok on my laptop but fail in pipeline?

CodePudding user response:

The default version of nuget embedded on the agent should not support your project. I advise you to use the task "NuGet tool installer" with the version you use on your computer before doing your nuget restore.

  • Related