After some research, I decided to replace the NuGetCommand (NuGet-Task) with the DotNetCoreCli "restore" task. First I had to switch the "vmImage" from "windows-latest" to "windows-2022" as it seems the latest one has a grace period of a few months (read more here). Just before that, I had many more of those "is not compatible with net60" errors. Not just from AutoMapper.
Here is my Azure DevOps Pipeline YAML for all that had the same struggle to migrate their pipeline to .NET 6 as a starting point.
trigger:
batch: true
branches:
include:
- main
stages:
- stage: Build_Release
pool:
vmImage: windows-2022
jobs:
- job: Build
variables:
buildConfiguration: 'Release'
solution: './SomeSolution.Name.sln'
continueOnError: false
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
feedsToUse: 'config'
nugetConfigPath: '.\NuGet.config'
externalFeedCredentials: 'Telerik NuGet Connection'
- task: VSBuild@1
displayName: 'Build Solution'
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:PublishProvider=FileSystem /p:ExcludeApp_Data=False /p:DeleteExistingFiles=True /p:PublishUrl=$(Build.ArtifactStagingDirectory) /p:Configuration=$(buildConfiguration)'
configuration: '$(buildConfiguration)'
maximumCpuCount: true
createLogFile: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'some-artifact-name'
publishLocation: 'Container'
Edit: Removed the UseDotNet-Task as it seems not to be required when using windows-2022. Link