Azure DevOps NuGet任务刚刚开始失败(缺少dotnet核心)

时间:2020-07-13 12:26:08

标签: azure-devops nuget

我最近发现我的Azure DevOps管道开始出现故障。最初,我以为我已经用最近的更改破坏了它,但是如果我在同一分支上运行相同的提交(注意,我已将master重命名为main ),则它在先前成功的情况下将失败:

enter image description here

这是我对管道的YAML:

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

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

- task: MSBuild@1
  displayName: "NET 4.0 Build"
  inputs:
    solution: '**\Expressive.csproj'
    configuration: 'Release'

- task: DotNetCoreCLI@2
  inputs:
    command: 'test'
    projects: '**/*.csproj'
    testRunTitle: 'Run all tests'

我在构建日志中发现了这个细节:

Errors in D:\a\1\s\Source\CSharp\Expressive\Expressive.Tests\Expressive.Tests.csproj
    Unable to resolve 'Microsoft.NETCore.App (>= 3.0.0)' for '.NETCoreApp,Version=v3.0'.
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.0.0/microsoft.netcore.dotnethostresolver.2.0.0.nupkg 39ms
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.2.0/microsoft.netcore.dotnethostresolver.2.2.0.nupkg 37ms
  OK https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/2.1.0/microsoft.netcore.dotnethostresolver.2.1.0.nupkg 38ms
  OK https://api.nuget.org/v3-flatcontainer/system.runtime.serialization.json/4.0.2/system.runtime.serialization.json.4.0.2.nupkg 953ms
  OK https://api.nuget.org/v3-flatcontainer/system.xml.xpath.xmldocument/4.0.1/system.xml.xpath.xmldocument.4.0.1.nupkg 955ms

因此,总结一下,我可以看到的唯一区别是我将master重命名为main的事实。如果这是造成问题的原因,我会感到很惊讶。有没有人看到或能够提供帮助?

1 个答案:

答案 0 :(得分:1)

更新

作为解决方法,请切换到dotnet restore任务来解决此问题。

故障排除:

您可以尝试在master分支上运行的管道中检查nuget restore任务使用的nuget版本。然后将其与主分支上运行的管道中使用的nuget版本进行比较,以查看它们是否一致。

enter image description here

如果它们不一致,则可以将NuGet工具安装程序任务添加到主分支管道,以使用与主分支管道相同的nuget版本。

enter image description here