我有一个
global.json
,看起来像这样:
{
"sdk": {
"version": "8.0.301",
"rollForward": "latestFeature"
}
}
据我所知,这意味着我希望它接受
8.0.xxx
,只要它不低于8.0.301。例如,8.0.302
和 8.0.400
都可以,但 8.1.x
或 x.x.x
则不行。
问题是我的Azure Pipeline只想安装
8.0.301
。在撰写本文时,8.0.302
已可用,并由 Microsoft 官方下载页面支持。
我的安装.NET SDK的Azure管道任务如下:
- task: UseDotNet@2
displayName: "Install .NET SDK"
inputs:
packageType: sdk
useGlobalJson: true
但是当它运行时,我看到以下日志:
Found version 8.0.301 in channel 8.0 for user specified version spec: 8.0.301
Getting URL to download .NET Core sdk version: 8.0.301.
Detecting OS platform to find correct download package for the OS.
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.238.1\externals\get-os-platform.ps1'"
Primary:win-x64
Detected platform (Primary): win-x64
Version 8.0.301 was not found in cache.
Downloading: https://download.visualstudio.microsoft.com/download/pr/7ac2d880-2d57-4008-850e-4b42b829c354/e1c92cb3b6a85f53cab6fa55b14b49e3/dotnet-sdk-8.0.301-win-x64.zip
Extracting downloaded package D:\a\_temp\7024317f-ea64-4710-afa8-0435e0f177ed.
Extracting archive
C:\Windows\system32\chcp.com 65001
Active code page: 65001
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\7024317f-ea64-4710-afa8-0435e0f177ed', 'D:\a\_temp\9404')"
Successfully installed .NET Core sdk version 8.0.301.
Creating global tool path and pre-pending to PATH.
Finishing: Install .NET SDK
即使应该下载
8.0.301
,为什么还要安装 8.0.302
?
了解更多信息:https://github.com/microsoft/azure-pipelines-tasks/issues/20065
global.json 和 rollForward 都有自己的用途:
The global.json file allows you to define which .NET SDK version is used when you run .NET CLI commands.
使用.NET V2任务不以同样的方式使用global.json:
Use global json: This checkbox indicates that **all versions from all global.json files will be used** to install the sdk versions. You can set the search root path with Working Directory.
很可能它只是查找版本号,而不重用版本策略,例如
rollForward
。
事实上,由于您正在安装一个 .NET SDK,并且没有选择安装的哪一个,所以这一切都是有意义的。
也许您应该按照 docs
中的建议使用任务的 Version 参数版本*:指定要安装的 .NET Core SDK 或运行时的版本。它 还可以让您始终获得次要或主要版本的最新版本 版本。请参阅下面的示例 示例:
To install 2.2.104 SDK, use 2.2.104 To install 2.2.1 runtime, use 2.2.1 To install 3.0.100-preview3-010431 sdk, use 3.0.100-preview3-010431 To install latest patch version of 2.1 sdk, use 2.1.x To install latest minor version of 2. sdk, use 2.x For getting more details about exact version, refer this link.
因此,对于您的用例,也许可以使用
8.0.3x
。实验是有序的,因为文档对于乐队版本不太清楚。