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

Azure devops Azure DevOps NuGet任务刚刚开始失败(缺少dotnet核心),azure-devops,nuget,Azure Devops,Nuget,我最近发现我的Azure DevOps管道开始出现故障。最初我假设我用最近的更改破坏了它,但是如果我在同一个分支上运行相同的提交(注意,我已将master重命名为main),那么它在以前成功时失败: 以下是我对管道的YAML: trigger: - master pool: vmImage: 'vs2017-win2016' steps: - task: NuGetCommand@2 displayName: "NuGet Restore" inputs:

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

以下是我对管道的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
。不过,如果这是问题的原因,我会感到相当惊讶。有人看到这一点或能够提供帮助吗?

更新

作为解决方法,请切换到dotnet还原任务以解决此问题

故障排除:

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

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


谢谢你的建议。我可以确认master和main都检测到相同版本的NuGet
检测到的NuGet版本4.1.0.2450/4.1.0
。但我注意到的一个细节是,NuGet Restore任务版本不同。主(工作)为
2.169.2
,主(故障)为
2.171.1
。我会看看我是否可以在这个分支上强制使用较旧的版本,看看这是否会有所不同。老实说,我还无法确定我是否可以指定一个任务的特定版本来使用
重命名的master to main
我对此感到困惑,azure devops中不应该有这样的功能,你是怎么做到的?此外,您可以检查两次生成运行的源代码是否不同。很抱歉,我没有在Azure DevOps中将master重命名为main。我从GitHub获取代码,并在那里重命名了该分支。我提到它只是因为这是我能看到的唯一的环境差异。您可以从我的屏幕截图中看到,管道每次都在构建提交。我现在已经解决了这个问题,一旦我回到笔记本电脑上,我可以更新这篇文章。很高兴听到这个问题可以通过使用
dotnet restore
任务来解决。我在答案中添加了这个变通方法。