-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use script to install ARM version of .NET on ARM because of a UseDotNet bug #3037
base: main
Are you sure you want to change the base?
Changes from all commits
c1259ae
dc376be
38c9c55
8b72afa
057e592
225dba2
e8d46b0
90a3b27
b76b1a0
1664a69
8dc4e37
ce6b751
c35a00b
ae6f181
b1f5573
cfa1ca7
4c875ae
263aa8e
46f0f8f
d4cb4a0
a1e1144
fb3448d
47ece3f
5dd1c9d
ff5b6b7
918e61d
f0aba78
4b077f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
################################################################################# | ||
# Licensed to the .NET Foundation under one or more agreements. # | ||
# The .NET Foundation licenses this file to you under the MIT license. # | ||
# See the LICENSE file in the project root for more information. # | ||
################################################################################# | ||
parameters: | ||
- name: version | ||
type: number | ||
default: 9 | ||
- name: sdk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just have this as a string with values of 'sdk' and 'runtime' - that way when it's passed into the later tasks, we don't have to have if expressions |
||
type: boolean | ||
default: false | ||
- name: windowsArchitecture # This is only used on Windows | ||
type: string | ||
default: '<auto>' | ||
values: | ||
- '<auto>' | ||
- 'x86' | ||
- 'x64' | ||
- 'arm' | ||
- 'arm64' | ||
- name: installDir | ||
type: string | ||
default: '' | ||
- name: usePreview | ||
type: boolean | ||
default: false | ||
|
||
# Reason for not using UseDotNet task: | ||
# "[BUG]: UseDotNet task installs x86 build on Windows arm64" | ||
# https://github.com/microsoft/azure-pipelines-tasks/issues/20300 | ||
# | ||
# Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml | ||
steps: | ||
- powershell: |- | ||
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" | ||
$NEW_DOTNET_ROOT = "${{parameters.installDir}}" | ||
|
||
if ('${{parameters.installDir}}' -eq '') { | ||
$NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" | ||
} else { | ||
$NEW_DOTNET_ROOT = "${{parameters.installDir}}" | ||
} | ||
|
||
if (!$${{parameters.sdk}}) { | ||
$runtime = "dotnet" | ||
} | ||
|
||
$quality = "GA" | ||
if ($${{parameters.usePreview}}) { | ||
$quality = "preview" | ||
} | ||
|
||
& ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality $quality -InstallDir $NEW_DOTNET_ROOT -Runtime $runtime -Architecture "${{parameters.windowsArchitecture}}" | ||
Write-Host "##vso[task.setvariable variable=DOTNET_ROOT]${NEW_DOTNET_ROOT}" | ||
Write-Host "##vso[task.prependpath]${NEW_DOTNET_ROOT}" | ||
Remove-Item dotnet-install.ps1 -ErrorAction:Ignore | ||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about instead of doing this as a condition buried in the task definition, let's move this a level higher and use the |
||
${{ if eq(parameters.sdk, true) }}: | ||
displayName: "Install .NET ${{parameters.version}} SDK (Win)" | ||
${{ else }}: | ||
displayName: "Install .NET ${{parameters.version}} (Win)" | ||
- task: UseDotNet@2 | ||
inputs: | ||
${{ if eq(parameters.sdk, true) }}: | ||
packageType: sdk | ||
${{ else }}: | ||
packageType: runtime | ||
version: '${{parameters.version}}.x' | ||
${{ if ne(parameters.installDir, '') }}: | ||
installationPath: '${{parameters.installDir}}' | ||
includePreviewVersions: ${{parameters.usePreview}} | ||
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) | ||
${{ if eq(parameters.sdk, true) }}: | ||
displayName: "Install .NET ${{parameters.version}} SDK (non-Win)" | ||
${{ else }}: | ||
displayName: "Install .NET ${{parameters.version}} (non-Win)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're working on improving our pipelines (and I'm pushing for some degree of uniformity), can we have these with: