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 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c1259ae
Use script to install .NET because of ARM bug
MichelZ Nov 26, 2024
dc376be
YAML
MichelZ Nov 26, 2024
38c9c55
Add back steps:
MichelZ Nov 26, 2024
8b72afa
Fix name
MichelZ Nov 26, 2024
057e592
Try without ./
MichelZ Nov 26, 2024
225dba2
Maybe they need to hang back a level
MichelZ Nov 26, 2024
e8d46b0
Replace CURL
MichelZ Nov 26, 2024
90a3b27
Switch to powershell
MichelZ Nov 26, 2024
b76b1a0
Need a Windows & non-Windows version
MichelZ Nov 26, 2024
1664a69
YAML
MichelZ Nov 26, 2024
8dc4e37
Use .0 for WIndows and .X for other
MichelZ Nov 26, 2024
ce6b751
Update install command to include Quality and only install Runtime wh…
MichelZ Nov 27, 2024
c35a00b
Improve way to specify SDK vs Runtime
MichelZ Nov 27, 2024
ae6f181
Make it a string
MichelZ Nov 27, 2024
b1f5573
Use whole number only
MichelZ Nov 27, 2024
cfa1ca7
We don't need to use "
MichelZ Nov 27, 2024
4c875ae
Add additional options, make output cleaner
MichelZ Nov 27, 2024
263aa8e
Runtime variables like Agent.OS do not work
MichelZ Nov 27, 2024
46f0f8f
Path to ensure-dotnet-version
MichelZ Nov 27, 2024
d4cb4a0
Condition not possible on template
MichelZ Nov 27, 2024
a1e1144
Improve version detection
MichelZ Nov 27, 2024
fb3448d
String
MichelZ Nov 27, 2024
47ece3f
booleans...
MichelZ Nov 27, 2024
5dd1c9d
Use SDK for X86, use installDir
MichelZ Nov 27, 2024
ff5b6b7
InstallDir
MichelZ Nov 27, 2024
918e61d
PS String comparison
MichelZ Nov 27, 2024
f0aba78
Cosmetics
MichelZ Nov 27, 2024
4b077f6
Merge branch 'main' of github.com:dotnet/SqlClient into fix-netcore-i…
mdaigle Feb 14, 2025
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 @@ -231,26 +231,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
Copy link
Contributor

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:

  • 4 space indents at each level
  • Extra line between parameter definitions and tasks
  • Sort parameters alphabetically

type: number
default: 9
- name: sdk
Copy link
Contributor

Choose a reason for hiding this comment

The 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'))
Copy link
Contributor

Choose a reason for hiding this comment

The 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(variables.Agent.OS, 'Windows_NT') }}: to conditionally include the tasks.

${{ 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