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

标签 .net nuget azure-pipelines invocationtargetexception

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

  • ##[error]The nuget command failed with exit code(1) and error(Error parsing solution file at d:\a\1\s\***.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of its dependencies. The system cannot find the file specified. d:\a\1\s\***.sln)

  • ##[error]Packages failed to restore

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

这是我的 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'

这是怎么回事?

最佳答案

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

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

关于.net - 管道上的调用目标已引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61096920/

相关文章:

visual-studio-2012 - VS、Nuget、TFS - 管理复杂的内部依赖结构

c# - 使用 Azure 门户将 .nupkg 文件上传到我的 Azure 函数

c# - 如何从 AzureDevOps Pipelines 中的解决方案缓存每个项目的 project.assets.json?

.net - WPF 中的等待不会返回到 UI 线程

c# - ASP.NET MVC : How to create a basic Pseudo Viewstate? 或者更好的解决方案?

c# - "Namespace ' x ' is not defined"尽管先调用 GetNamespacesInScope

.net - Entity Framework Code First Migrations 认为有一个不应该存在的变化

asp.net-core - 有没有办法使用 NuGet 或其他方式打包 ASP.NET Core 应用程序?

azure-devops - 将 secureObject 数组作为 VSTS 变量传递

azure-pipelines - 触发构建推送标签