管道上的调用目标已引发异常

H. *_*lyn 2 .net invocationtargetexception nuget azure-pipelines

我已经为 .NET Framework 项目创建了一个构建管道。当管道由拉取请求触发时,我在任务中遇到以下错误:“NuGet 恢复”

  • ##[错误]nuget 命令失败,退出代码(1) 和错误(解析解决方案文件时出错d:\a\1\s\***.sln:调用目标已引发异常。无法加载项目文件。无法加载文件或程序集Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a或其依赖项之一。系统找不到指定的文件。 d:\a\1\s\***.sln

  • ##[error]包恢复失败

当我尝试在与目标分支合并后在本地计算机上编译解决方案时,没有任何冲突或错误。

这是我的 YML 文件:

pool:
  name: Hosted Windows 2019 with VS2019
  demands:
  - msbuild
  - visualstudio
  - vstest

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2 # --> This task fails.
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '***.sln'

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: '***.sln'
    platform: 'any cpu'
    configuration: 'release'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**\bin\**\*.pdb'
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact drop'
  inputs:
    PathtoPublish: ***
    ArtifactName: 'drop wa'
Run Code Online (Sandbox Code Playgroud)

它出什么问题了?

Kam*_*l C 5

目前 nuget 任务似乎存在问题。您可能会尝试将版本更改为 5.4,因为这似乎可以解决某些人(包括我)的问题。

请参阅下面的链接: https://developercommunity.visualstudio.com/content/problem/978914/nuget-restore-on-hosted-agent-builds-cannot-find-s.html