简体   繁体   中英

Problem in Azure DevOps pipeline restoring AutoMapper NuGet package in .net 6

I get the following error message when my pipeline is being run:

Package AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.1 is not compatible with net60 (.NETFramework,Version=v6.0). Package AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.1 supports: netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETFramework,Version=v6.0.)

Is there something I can do here or do I need to wait for the AutoMapper team to update it?

From the error message AutoMapper.extension package is not supported with .net 6.0 project.

So you can use the compatible AutoMapper.extension package version 2.0 to work with .net 6.0 project.

As .net 6.0 projects supports netstandard2.0 packages.

It looks like the error in my case has nothing to do with Automapper. I had to create a completely new pipeline which fixed my issues.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM