.net - 在 Azure DevOps 中获取 UseDotNet@2 以使用 vmImage 的 dotnet SDK(或来自缓存的 SDK)

标签 .net azure azure-devops azure-pipelines

我有一个带有代理的 Azure DevOps 管道,步骤如下:

pool:
  vmImage: 'windows-latest'

# ....

steps:
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '5.x'

代理解析为 Windows 2022,MSDN 链接为 this list of installed software其中包括 5.0.406 作为 dotnet 的最新 5.x 版本。因此,我认为该步骤会看到该软件已经可用并且不会执行任何操作。

相反,该步骤需要 25 秒才能下载?以下是 Azure DevOps 的输出:

2022-03-31T09:32:37.5205829Z ##[section]Starting: UseDotNet
2022-03-31T09:32:37.5326189Z ==============================================================================
2022-03-31T09:32:37.5326523Z Task         : Use .NET Core
2022-03-31T09:32:37.5327080Z Description  : Acquires a specific version of the .NET Core SDK from the internet or the local cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks. Additionally provides proxy support.
2022-03-31T09:32:37.5327618Z Version      : 2.198.0
2022-03-31T09:32:37.5327838Z Author       : Microsoft Corporation
2022-03-31T09:32:37.5328057Z Help         : https://aka.ms/AA4xgy0
2022-03-31T09:32:37.5328346Z ==============================================================================
2022-03-31T09:32:38.1175143Z Tool to install: .NET Core sdk version 5.x.
2022-03-31T09:32:40.3450298Z Found version 5.0.406 in channel 5.0 for user specified version spec: 5.x
2022-03-31T09:32:40.3901604Z Version 5.0.406 was not found in cache.
2022-03-31T09:32:40.3902218Z Getting URL to download .NET Core sdk version: 5.0.406.
2022-03-31T09:32:40.3903044Z Detecting OS platform to find correct download package for the OS.
2022-03-31T09:32:40.3919001Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\UseDotNet_b0ce7256-7898-45d3-9cb5-176b752bfea6\2.198.0\externals\get-os-platform.ps1'"
2022-03-31T09:32:40.7335953Z Primary:win-x64
2022-03-31T09:32:40.7337064Z Detected platform (Primary): win-x64
2022-03-31T09:32:40.7357212Z Downloading: https://download.visualstudio.microsoft.com/download/pr/aa30e704-a085-4ed4-bcbd-9f3491b7722b/05a1aefc5c841a1faa7eae08a5cec110/dotnet-sdk-5.0.406-win-x64.zip
2022-03-31T09:32:42.0180110Z Extracting downloaded package D:\a\_temp\33032e6d-ebd8-4f81-951e-779d5384477e.
2022-03-31T09:32:42.0188915Z Extracting archive
2022-03-31T09:32:42.0229477Z [command]C:\Windows\system32\chcp.com 65001
2022-03-31T09:32:42.0330177Z Active code page: 65001
2022-03-31T09:32:42.0554435Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('D:\a\_temp\33032e6d-ebd8-4f81-951e-779d5384477e', 'D:\a\_temp\99ba')"
2022-03-31T09:33:02.8364659Z Successfully installed .NET Core sdk version 5.0.406.
2022-03-31T09:33:02.8381246Z Creating global tool path and pre-pending to PATH.
2022-03-31T09:33:02.8488020Z ##[section]Finishing: UseDotNet

如何确保从 vmImage 已安装的软件或某种缓存中获取我的 dotnet SDK?我很想在我的构建中重新获得这 25 秒...

最佳答案

在撰写本文时,似乎 this is an open issue in Azure Devops ,顺便说一句,就在这个 Stack Overflow 问题创建前几周 one user commented on GitHub :

Downloading .NET 5.x takes 30 seconds while it's already on the windows-latest image. This costs us time, and it costs Microsoft precious server resources.

这似乎是完全相同的问题。

我发布此“答案”是为了提高可见性。也许其他人(a)可以在答案中发布解决方法,或者(b)将来可以添加真正的答案?

关于.net - 在 Azure DevOps 中获取 UseDotNet@2 以使用 vmImage 的 dotnet SDK(或来自缓存的 SDK),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71690289/

相关文章:

c# - 删除 WinForms 中的 SplitContainer 面板填充

c# - 为什么后续的直接方法调用比第一次调用快很多?

c# - 跳过 OnActionExecuted 执行

c# - 异步/等待指导 : Intrinsic Signature Proliferation

python - 如何使用python快速发送消息到azure队列存储?

azure - 如何在 azure devops 中交换插槽

azure - Azure HTTP 函数中缺少属性方向

redirect - Azure 云服务 SSL 从暂存槽重定向到生产槽

sql - Azure DevOps SQL 数据库部署

azure - 如何在 Azure 管道任务 AzureResourceGroupDeployment 中添加条件来 overrideParameters