Skip to content
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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions eng/pipelines/common/templates/jobs/ci-run-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,26 +217,17 @@ jobs:
referenceType: ${{ parameters.buildType }}
testSet: ${{ parameters.testSet }}
operatingSystem: ${{ parameters.operatingSystem }}

- ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}: # run x86 tests
- powershell: |
dotnet --info

Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1

# install .net x86
$version = "LTS"
if (!"${{parameters.targetFramework }}".StartsWith("net4"))
{
$version = "${{parameters.targetFramework }}".Substring(3, "${{parameters.targetFramework }}".Length-3)
}

.\dotnet-install.ps1 -Channel $version -Architecture x86 -InstallDir "$(dotnetx86RootPath)"

$(dotnetx86RootPath)dotnet.exe --info
displayName: 'Install .NET x86 '
condition: ne(variables['dotnetx86RootPath'], '')

- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
- template: ../steps/ensure-dotnet-version.yml
parameters:
sdk: true
${{ if not(startsWith(parameters.targetFramework, 'net4')) }}:
version: ${{ split(replace(parameters.targetFramework, 'net', ''), '.')[0] }}
windowsArchitecture: x86
installDir: $(dotnetx86RootPath)

- template: ../steps/run-all-tests-step.yml@self
parameters:
debug: ${{ parameters.debug }}
Expand Down
18 changes: 8 additions & 10 deletions eng/pipelines/common/templates/steps/ci-prebuild-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ parameters:
- Package

steps:
- task: UseDotNet@2
displayName: 'Use .NET 9.x sdk'
inputs:
packageType: sdk
version: '9.x'
- template: ensure-dotnet-version.yml
parameters:
sdk: true
version: 9

- task: UseDotNet@2
displayName: 'Install .NET 8.x runtime'
inputs:
packageType: runtime
version: '8.x'
- template: ensure-dotnet-version.yml
parameters:
sdk: false
version: 8

- ${{if eq(parameters.debug, true)}}:
- powershell: |
Expand Down
12 changes: 0 additions & 12 deletions eng/pipelines/common/templates/steps/ci-project-build-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ parameters:
- all

steps:
- task: UseDotNet@2
displayName: 'Use .NET 9.x sdk'
inputs:
packageType: sdk
version: '9.x'

- task: UseDotNet@2
displayName: 'Install .NET 8.x runtime'
inputs:
packageType: runtime
version: '8.x'

- ${{ if or(eq(parameters.operatingSystem, 'Windows'), eq(parameters.operatingSystem, 'deferedToRuntime')) }}:
- ${{ if or(eq(parameters.build, 'MDS'), eq(parameters.build, 'all')) }}:
- task: MSBuild@1
Expand Down
77 changes: 77 additions & 0 deletions eng/pipelines/common/templates/steps/ensure-dotnet-version.yml
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
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'))
${{ 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)"
Loading