azure-devops - 无法在 Azure DevOps Build Pipeline 中使用 .NET SDK 代理

标签 azure-devops azure-pipelines

我有一个 ASP.NET Core 2.1 并添加了一个 Microsoft.WindowsAzure.Storage 的 nuget 包,但是在将代码推送到 repo 后,构建管道在运行构建代理时出现包错误,是否有必要在构建中添加任何其他代理BUILD、RESTORE、TEST 和 PUBLISH 以外的管道。
[错误]错误:进程“C:\hostedtoolcache\windows\dotnet\dotnet.exe”失败,退出代码为 1
信息:Azure Pipelines 托管代理已更新为包含 .Net Core 3.x SDK/Runtime 以及 2.2 和 2.1。除非您为您的项目锁定了 SDK 版本,否则可能会选择 3.x SDK,与以前的版本相比,它可能具有破坏性行为。
这是它在运行管道时显示的错误。

最佳答案

如错误信息所示,不建议调用latest 3.x sdk恢复、构建、测试、发布以 asp .net core 2.1 为目标的项目.

虽然在大多数情况下构建可以通过,但发布步骤(任务)可能会遇到这个问题:

enter image description here

解决问题:

我们应该指定 .net core我们要在运行 restore,build,test,publish 等任务之前使用的 sdk 版本...

我们可以添加 use .net core sdk task在其他类似这样的 .net 核心任务之前拿起 .net core 2.1.x相关版本来执行以下任务,而不是使用 .net core 3.x sdk :

经典用户界面:

enter image description here

指定 2.1.x+Include Preview Versions将选择最新版本的 2.1 sdk。

yaml:

如果您使用 yaml 格式而不是经典的 UI 格式来配置管道,它的 yaml 格式类似于:

steps:
- task: UseDotNet@2
  displayName: 'Use .Net Core sdk 2.1.x'
  inputs:
    packageType: sdk
    version: 2.1.x
    installationPath: $(Agent.ToolsDirectory)/dotnet
    includePreviewVersions: true

希望对您有所帮助,如果我有任何误解,请随时纠正我:)

关于azure-devops - 无法在 Azure DevOps Build Pipeline 中使用 .NET SDK 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59474379/

相关文章:

git - 通过 SSH 从 VSTS 克隆 Git 存储库需要密码!意外

git - 您如何使用 LibGit2Sharp 向 VSTS 进行身份验证?

powershell - Start-Job with credential in 自定义任务问题

github - "Resource not accessible by integration"尝试创建触发器时

azure-devops - 在 Azure Pipelines 上运行 CUDA 单元测试

azure - 构建期间无法将标记添加到 Azure 管道

testing - 无法弄清楚如何在构建测试中使用 "link"按钮

python - AzureML 推理架构中出现 "list index out of range"错误

azure-devops - 我们如何阅读 Azure DevOps 任务日志?

ios - 如何从 Azure Pipeline 在 Bitbucket 中更新构建状态?