【问题标题】:Azure DevOps pipeline build fails due to version conflict within Microsoft.AspNetCore packages由于 Microsoft.AspNetCore 包中的版本冲突,Azure DevOps 管道构建失败
【发布时间】:2019-08-14 19:15:40
【问题描述】:

我一直在尝试使用 Azure DevOps 设置适当的 devops 管道。我的问题与其他帖子非常相似,但没有解决我的问题: NU1607: Version conflict detected for Microsoft.AspNetCore.Antiforgery. Reference the package directly from the project to resolve this issue. botProj (>= 1.0.0) -> Bot.Builder.Community.Middleware.Typing (>= 1.0.82) -> Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.1.1) -> Microsoft.AspNetCore.Antiforgery (>= 2.1.1) botProj (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Antiforgery (>= 2.1.0).)

如果我像建议的那样直接添加此参考,那么它只会给我一个新参考。我宁愿不必直接添加每一个。

在这篇文章中: How do I resolve version conflicts in aspnet core 2.1? (2.1.1 >= 2.1.0-rc1-final)

答案表明我只需要在我的.csproj 文件中设置<PackageReference Include="Microsoft.AspNetCore.App" />。 我已经这样做了,但仍然遇到同样的错误。

在这篇文章中: 建议使用dotnet-restore,我相信我已将其放入我的azure-pipelines.yml 但老实说这可能是错误的命令,所以我将发布我的管道 Azure DevOps build pipline constantly giving version conflict on every package

这是我的azure-pipelines.yml

vmImage: 'windows-2019'

trigger:
- dev/mybranch

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '2.2.101'

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'config'
    nugetConfigPath: 'ibibot_ops/NuGet.Config'

- task: VSBuild@1
...
- task: VSTest@2
...

我将把我的.csproj 发布在一个要点中: https://gist.github.com/MilesWilde/e85f08f5bce40fa63222bbdcffc808cc

我也有一个测试botProj.test.csproj,但它似乎不会影响错误,所以我不会发布它,除非它有意义。

对此的任何帮助表示赞赏。谢谢。

【问题讨论】:

    标签: .net azure-devops botframework


    【解决方案1】:

    通过在我的管道中为NugetToolInstaller@0 任务指定一个版本并使用DotNetCoreInstaller@0 来解决这个问题。这是我的最终 .yml,删除了一些信息

    steps:
    - task: DotNetCoreInstaller@0
      displayName: 'Use .NET Core sdk 2.2.101'
      inputs:
        version: 2.2.101
      continueOnError: true
    
    - task: NuGetToolInstaller@0
      displayName: 'Use NuGet 4.9.1'
      inputs:
        versionSpec: 4.9.1
    
    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        command: 'restore'
        restoreSolution: '**/*.sln'
        feedsToUse: 'config'
        nugetConfigPath: './NuGet.Config'
    
    - task: VSBuild@1
    ...
    
    - task: DotNetCoreCLI@2
    ...
    
    - task: PublishCodeCoverageResults@1
    ...
    

    【讨论】:

    • 感谢您在此处分享您的解决方案,您可以接受它作为答案,这样它可以帮助遇到相同问题的其他社区成员,我们可以存档此线程,谢谢。
    猜你喜欢
    • 2022-09-27
    • 2021-12-28
    • 2019-10-21
    • 2021-01-03
    • 2020-01-01
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多