From c1259ae9284e7b29d47deeff014ca22a8b4a0f8b Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 16:17:24 +0100 Subject: [PATCH 01/27] Use script to install .NET because of ARM bug --- .../templates/steps/ci-prebuild-step.yml | 18 ++++++------- .../templates/steps/ci-project-build-step.yml | 13 ---------- .../templates/steps/ensure-dotnet-version.yml | 26 +++++++++++++++++++ 3 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 eng/pipelines/common/templates/steps/ensure-dotnet-version.yml diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index b8771702dd..a54c6c5c18 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -20,17 +20,15 @@ parameters: - Package steps: -- task: UseDotNet@2 - displayName: 'Use .NET 9.x sdk' - inputs: - packageType: sdk - version: '9.x' +- template: ./steps-ensure-dotnet-version.yml + parameters: + sdk: true + version: '9.0' -- task: UseDotNet@2 - displayName: 'Install .NET 8.x runtime' - inputs: - packageType: runtime - version: '8.x' +- template: ./steps-ensure-dotnet-version.yml + parameters: + sdk: false + version: '8.0' - ${{if eq(parameters.debug, true)}}: - powershell: | diff --git a/eng/pipelines/common/templates/steps/ci-project-build-step.yml b/eng/pipelines/common/templates/steps/ci-project-build-step.yml index 9f0d7ad863..1c2d6cc500 100644 --- a/eng/pipelines/common/templates/steps/ci-project-build-step.yml +++ b/eng/pipelines/common/templates/steps/ci-project-build-step.yml @@ -33,19 +33,6 @@ parameters: - AKV - 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 diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml new file mode 100644 index 0000000000..2118aa4214 --- /dev/null +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -0,0 +1,26 @@ +parameters: +- name: version + type: string + default: "9.0" +- name: sdk + 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 +# +# Herein we replicate 90% of the meaningful logic in that task. +# Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml +steps: +- pwsh: |- + curl.exe -J -L -O "https://dot.net/v1/dotnet-install.ps1" + $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" + & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT + 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 + ${{ if eq(parameters.sdk, true) }}: + displayName: "Install .NET ${{parameters.version}} SDK" + ${{ else }}: + displayName: "Install .NET ${{parameters.version}}" \ No newline at end of file From dc376be14abe42cf4c12aa89b689869e982d358d Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 16:49:15 +0100 Subject: [PATCH 02/27] YAML --- eng/pipelines/common/templates/steps/ci-prebuild-step.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index a54c6c5c18..1caa6cff8f 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -20,12 +20,12 @@ parameters: - Package steps: -- template: ./steps-ensure-dotnet-version.yml + - template: ./steps-ensure-dotnet-version.yml parameters: sdk: true version: '9.0' -- template: ./steps-ensure-dotnet-version.yml + - template: ./steps-ensure-dotnet-version.yml parameters: sdk: false version: '8.0' From 38c9c55c6f3c027c0e14c35d1d206b7a6c147264 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 16:55:13 +0100 Subject: [PATCH 03/27] Add back steps: --- eng/pipelines/common/templates/steps/ci-project-build-step.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/common/templates/steps/ci-project-build-step.yml b/eng/pipelines/common/templates/steps/ci-project-build-step.yml index 1c2d6cc500..205f908599 100644 --- a/eng/pipelines/common/templates/steps/ci-project-build-step.yml +++ b/eng/pipelines/common/templates/steps/ci-project-build-step.yml @@ -33,6 +33,7 @@ parameters: - AKV - all +steps: - ${{ if or(eq(parameters.operatingSystem, 'Windows'), eq(parameters.operatingSystem, 'deferedToRuntime')) }}: - ${{ if or(eq(parameters.build, 'MDS'), eq(parameters.build, 'all')) }}: - task: MSBuild@1 From 8b72afa400f72d07f7edb7d6b6de6443fbb9e557 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 16:57:43 +0100 Subject: [PATCH 04/27] Fix name --- eng/pipelines/common/templates/steps/ci-prebuild-step.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index 1caa6cff8f..8a3b9e9aba 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -20,12 +20,12 @@ parameters: - Package steps: - - template: ./steps-ensure-dotnet-version.yml + - template: ./ensure-dotnet-version.yml parameters: sdk: true version: '9.0' - - template: ./steps-ensure-dotnet-version.yml + - template: ./ensure-dotnet-version.yml parameters: sdk: false version: '8.0' From 057e5926d620a0364fc995eecd69b1dd0bb86e1c Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:05:45 +0100 Subject: [PATCH 05/27] Try without ./ --- eng/pipelines/common/templates/steps/ci-prebuild-step.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index 8a3b9e9aba..6b2002652d 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -20,12 +20,12 @@ parameters: - Package steps: - - template: ./ensure-dotnet-version.yml + - template: ensure-dotnet-version.yml parameters: sdk: true version: '9.0' - - template: ./ensure-dotnet-version.yml + - template: ensure-dotnet-version.yml parameters: sdk: false version: '8.0' From 225dba2cbf477a13ccf61362737cce2e395631d1 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:09:37 +0100 Subject: [PATCH 06/27] Maybe they need to hang back a level --- .../common/templates/steps/ci-prebuild-step.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index 6b2002652d..79b903fd33 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -20,15 +20,15 @@ parameters: - Package steps: - - template: ensure-dotnet-version.yml - parameters: - sdk: true - version: '9.0' +- template: ensure-dotnet-version.yml + parameters: + sdk: true + version: '9.0' - - template: ensure-dotnet-version.yml - parameters: - sdk: false - version: '8.0' +- template: ensure-dotnet-version.yml + parameters: + sdk: false + version: '8.0' - ${{if eq(parameters.debug, true)}}: - powershell: | From e8d46b06a25ef6d30be9435d108b45f0c7601d8d Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:17:29 +0100 Subject: [PATCH 07/27] Replace CURL --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 2118aa4214..63e88e7271 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -14,7 +14,7 @@ parameters: # Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml steps: - pwsh: |- - curl.exe -J -L -O "https://dot.net/v1/dotnet-install.ps1" + Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT Write-Host "##vso[task.setvariable variable=DOTNET_ROOT]${NEW_DOTNET_ROOT}" From 90a3b276bf901654b4a31d1c6136d5ac0c16ec87 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:24:19 +0100 Subject: [PATCH 08/27] Switch to powershell --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 63e88e7271..8ddd72dfc8 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -13,7 +13,7 @@ parameters: # Herein we replicate 90% of the meaningful logic in that task. # Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml steps: -- pwsh: |- +- powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT From b76b1a099e1bae1c25b19f294ee1888c7f1ad445 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:41:12 +0100 Subject: [PATCH 09/27] Need a Windows & non-Windows version --- .../templates/steps/ensure-dotnet-version.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 8ddd72dfc8..b77a297e98 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -20,6 +20,20 @@ steps: 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" + ${{ else }}: + displayName: "Install .NET ${{parameters.version}}" +- task: + name: UseDotNet@2 + inputs: + ${{ if eq(parameters.sdk, true) }}: + packageType: sdk + ${{ else }}: + packageType: runtime + version: '${{parameters.version}}' + condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) ${{ if eq(parameters.sdk, true) }}: displayName: "Install .NET ${{parameters.version}} SDK" ${{ else }}: From 1664a69b5cfd60538a6c8bd689328f929dab88f5 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:42:35 +0100 Subject: [PATCH 10/27] YAML --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index b77a297e98..a6c7511e3c 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -25,8 +25,7 @@ steps: displayName: "Install .NET ${{parameters.version}} SDK" ${{ else }}: displayName: "Install .NET ${{parameters.version}}" -- task: - name: UseDotNet@2 +- task: UseDotNet@2 inputs: ${{ if eq(parameters.sdk, true) }}: packageType: sdk From 8dc4e371556bf7c78fd36f78d42d99e998612298 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Tue, 26 Nov 2024 17:49:44 +0100 Subject: [PATCH 11/27] Use .0 for WIndows and .X for other --- .../common/templates/steps/ensure-dotnet-version.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index a6c7511e3c..a26e6ed70b 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -1,7 +1,7 @@ parameters: - name: version type: string - default: "9.0" + default: "9" - name: sdk type: boolean default: false @@ -16,7 +16,7 @@ steps: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" - & ./dotnet-install.ps1 -Channel "${{parameters.version}}" -InstallDir $NEW_DOTNET_ROOT + & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -InstallDir $NEW_DOTNET_ROOT 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 @@ -31,7 +31,7 @@ steps: packageType: sdk ${{ else }}: packageType: runtime - version: '${{parameters.version}}' + version: '${{parameters.version}}.x' condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) ${{ if eq(parameters.sdk, true) }}: displayName: "Install .NET ${{parameters.version}} SDK" From ce6b751befdae086d75bcb31bd2bf4d8ab53a82f Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 09:29:32 +0100 Subject: [PATCH 12/27] Update install command to include Quality and only install Runtime when SDK is false --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index a26e6ed70b..9a1556abb9 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -16,7 +16,7 @@ steps: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" - & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -InstallDir $NEW_DOTNET_ROOT + & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality GA -InstallDir $NEW_DOTNET_ROOT ${{ if eq(parameters.sdk, false) }}: -Runtime dotnet ${{ endif }} 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 From c35a00bad901adcd9482422dc365f70a64a575ce Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 09:49:02 +0100 Subject: [PATCH 13/27] Improve way to specify SDK vs Runtime --- .../common/templates/steps/ensure-dotnet-version.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 9a1556abb9..2e47b57b4b 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -16,7 +16,11 @@ steps: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" - & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality GA -InstallDir $NEW_DOTNET_ROOT ${{ if eq(parameters.sdk, false) }}: -Runtime dotnet ${{ endif }} + $useSdk = [bool]${{parameters.sdk}} + if (!$useSdk) { + $runtime = "dotnet" + } + & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality GA -InstallDir $NEW_DOTNET_ROOT -Runtime $runtime 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 From ae6f181d3e30b9a0f089444eae59e1f355b47336 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 09:55:46 +0100 Subject: [PATCH 14/27] Make it a string --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 2e47b57b4b..5f6921ee62 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -16,7 +16,7 @@ steps: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" - $useSdk = [bool]${{parameters.sdk}} + $useSdk = [bool]"${{parameters.sdk}}" if (!$useSdk) { $runtime = "dotnet" } From b1f557336a2988d28d9d6fd6f46d39114ed31551 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 10:13:21 +0100 Subject: [PATCH 15/27] Use whole number only --- eng/pipelines/common/templates/steps/ci-prebuild-step.yml | 4 ++-- .../common/templates/steps/ensure-dotnet-version.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index 79b903fd33..ed730f0f0d 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -23,12 +23,12 @@ steps: - template: ensure-dotnet-version.yml parameters: sdk: true - version: '9.0' + version: '9' - template: ensure-dotnet-version.yml parameters: sdk: false - version: '8.0' + version: '8' - ${{if eq(parameters.debug, true)}}: - powershell: | diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 5f6921ee62..696a75a75d 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -1,6 +1,6 @@ parameters: - name: version - type: string + type: number default: "9" - name: sdk type: boolean From cfa1ca7818d354a6beaf5f30b4caffa3340d5f4c Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 10:14:07 +0100 Subject: [PATCH 16/27] We don't need to use " --- eng/pipelines/common/templates/steps/ci-prebuild-step.yml | 4 ++-- .../common/templates/steps/ensure-dotnet-version.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml index ed730f0f0d..7e4fb0ac65 100644 --- a/eng/pipelines/common/templates/steps/ci-prebuild-step.yml +++ b/eng/pipelines/common/templates/steps/ci-prebuild-step.yml @@ -23,12 +23,12 @@ steps: - template: ensure-dotnet-version.yml parameters: sdk: true - version: '9' + version: 9 - template: ensure-dotnet-version.yml parameters: sdk: false - version: '8' + version: 8 - ${{if eq(parameters.debug, true)}}: - powershell: | diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 696a75a75d..b385dcb3aa 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -1,7 +1,7 @@ parameters: - name: version type: number - default: "9" + default: 9 - name: sdk type: boolean default: false From 4c875ae01b502f5ed925ea0a08d6ab6fb37daa14 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 10:54:07 +0100 Subject: [PATCH 17/27] Add additional options, make output cleaner --- .../templates/jobs/ci-run-tests-job.yml | 27 +++++---------- .../templates/steps/ensure-dotnet-version.yml | 33 ++++++++++++++++--- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml index 66a2614c3e..ec3e824634 100644 --- a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml +++ b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml @@ -217,26 +217,15 @@ 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'], '') - + - template: ensure-dotnet-version.yml + parameters: + sdk: false + version: split(replace(${{ parameters.targetFramework }}, 'net', ''), '.')[0] + windowsArchitecture: x86 + condition: and(ne(variables['dotnetx86RootPath'], ''), not(startsWith(parameters.targetFramework, 'net4'))) + - template: ../steps/run-all-tests-step.yml@self parameters: debug: ${{ parameters.debug }} diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index b385dcb3aa..68dd4b5b1b 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -5,30 +5,52 @@ parameters: - name: sdk type: boolean default: false +- name: windowsArchitecture # This is only used on Windows + type: string + default: '' + values: + - '' + - 'x86' + - 'x64' + - 'arm' + - 'arm64' +- name: installDir + type: string + default: '$(Agent.ToolsDirectory)\dotnet' +- 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 # -# Herein we replicate 90% of the meaningful logic in that task. # Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml steps: +${{ if eq(variables['Agent.OS'], 'Windows_NT') }}: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" - $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" + $NEW_DOTNET_ROOT = "${{parameters.installDir}}" $useSdk = [bool]"${{parameters.sdk}}" if (!$useSdk) { $runtime = "dotnet" } - & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality GA -InstallDir $NEW_DOTNET_ROOT -Runtime $runtime + + $quality = "GA" + $usePreview = [bool]"${{parameters.usePreview}}" + if ($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" ${{ else }}: displayName: "Install .NET ${{parameters.version}}" +${{ else }}: - task: UseDotNet@2 inputs: ${{ if eq(parameters.sdk, true) }}: @@ -36,7 +58,8 @@ steps: ${{ else }}: packageType: runtime version: '${{parameters.version}}.x' - condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) + installationPath: '${{parameters.installDir}}' + invludePreviewVersions: ${{parameters.usePreview}} ${{ if eq(parameters.sdk, true) }}: displayName: "Install .NET ${{parameters.version}} SDK" ${{ else }}: From 263aa8ecc3a9079b972945445bbc264e7065701b Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 10:59:20 +0100 Subject: [PATCH 18/27] Runtime variables like Agent.OS do not work --- .../templates/steps/ensure-dotnet-version.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 68dd4b5b1b..d0dafc0b4e 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -27,7 +27,6 @@ parameters: # # Borrowed from: https://github.com/microsoft/PowerToys/blob/main/.pipelines/v2/templates/steps-ensure-dotnet-version.yml steps: -${{ if eq(variables['Agent.OS'], 'Windows_NT') }}: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "${{parameters.installDir}}" @@ -46,11 +45,11 @@ ${{ if eq(variables['Agent.OS'], 'Windows_NT') }}: 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" + displayName: "Install .NET ${{parameters.version}} SDK (Windows)" ${{ else }}: - displayName: "Install .NET ${{parameters.version}}" -${{ else }}: + displayName: "Install .NET ${{parameters.version}} (Windows)" - task: UseDotNet@2 inputs: ${{ if eq(parameters.sdk, true) }}: @@ -59,8 +58,9 @@ ${{ else }}: packageType: runtime version: '${{parameters.version}}.x' installationPath: '${{parameters.installDir}}' - invludePreviewVersions: ${{parameters.usePreview}} + includePreviewVersions: ${{parameters.usePreview}} + condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) ${{ if eq(parameters.sdk, true) }}: - displayName: "Install .NET ${{parameters.version}} SDK" + displayName: "Install .NET ${{parameters.version}} SDK (Other OS)" ${{ else }}: - displayName: "Install .NET ${{parameters.version}}" \ No newline at end of file + displayName: "Install .NET ${{parameters.version}} (Other OS)" \ No newline at end of file From 46f0f8f5c6f913dc3ee73b7f152725dec7609598 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 11:03:02 +0100 Subject: [PATCH 19/27] Path to ensure-dotnet-version --- eng/pipelines/common/templates/jobs/ci-run-tests-job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml index ec3e824634..c022364cba 100644 --- a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml +++ b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml @@ -219,7 +219,7 @@ jobs: operatingSystem: ${{ parameters.operatingSystem }} - ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}: # run x86 tests - - template: ensure-dotnet-version.yml + - template: ../steps/ensure-dotnet-version.yml parameters: sdk: false version: split(replace(${{ parameters.targetFramework }}, 'net', ''), '.')[0] From d4cb4a0e63df6e24ba6816851e9b41ff873511d2 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 11:06:00 +0100 Subject: [PATCH 20/27] Condition not possible on template --- .../common/templates/jobs/ci-run-tests-job.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml index c022364cba..a9ba5f6fe5 100644 --- a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml +++ b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml @@ -219,12 +219,12 @@ jobs: operatingSystem: ${{ parameters.operatingSystem }} - ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}: # run x86 tests - - template: ../steps/ensure-dotnet-version.yml - parameters: - sdk: false - version: split(replace(${{ parameters.targetFramework }}, 'net', ''), '.')[0] - windowsArchitecture: x86 - condition: and(ne(variables['dotnetx86RootPath'], ''), not(startsWith(parameters.targetFramework, 'net4'))) + - ${{ if and(ne(variables['dotnetx86RootPath'], ''), not(startsWith(parameters.targetFramework, 'net4'))) }}: + - template: ../steps/ensure-dotnet-version.yml + parameters: + sdk: false + version: split(replace(${{ parameters.targetFramework }}, 'net', ''), '.')[0] + windowsArchitecture: x86 - template: ../steps/run-all-tests-step.yml@self parameters: From a1e11444cbdd82402938d64f5cce5320b388215c Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 11:09:00 +0100 Subject: [PATCH 21/27] Improve version detection --- eng/pipelines/common/templates/jobs/ci-run-tests-job.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml index a9ba5f6fe5..a053d76a27 100644 --- a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml +++ b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml @@ -223,7 +223,7 @@ jobs: - template: ../steps/ensure-dotnet-version.yml parameters: sdk: false - version: split(replace(${{ parameters.targetFramework }}, 'net', ''), '.')[0] + version: ${{ split(replace(parameters.targetFramework, 'net', ''), '.')[0] }} windowsArchitecture: x86 - template: ../steps/run-all-tests-step.yml@self From fb3448db46dc8f0b3d5eb3addad58279dc8b678a Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 11:18:16 +0100 Subject: [PATCH 22/27] String --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index d0dafc0b4e..582138e03c 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -41,7 +41,7 @@ steps: $quality = "preview" } - & ./dotnet-install.ps1 -Channel "${{parameters.version}}.0" -Quality $quality -InstallDir $NEW_DOTNET_ROOT -Runtime $runtime -Architecture ${{parameters.windowsArchitecture}} + & ./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 From 47ece3f314d5c8d679515556108e7ce1f0e1ef50 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 11:53:24 +0100 Subject: [PATCH 23/27] booleans... --- .../common/templates/steps/ensure-dotnet-version.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 582138e03c..328f0eee1f 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -30,14 +30,13 @@ steps: - powershell: |- Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "${{parameters.installDir}}" - $useSdk = [bool]"${{parameters.sdk}}" - if (!$useSdk) { + + if (!$${{parameters.sdk}}) { $runtime = "dotnet" } $quality = "GA" - $usePreview = [bool]"${{parameters.usePreview}}" - if ($usePreview) { + if ($${{parameters.usePreview}}) { $quality = "preview" } From 5dd1c9ddc4c317c55942836c9a6171a60379929b Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 12:57:10 +0100 Subject: [PATCH 24/27] Use SDK for X86, use installDir --- eng/pipelines/common/templates/jobs/ci-run-tests-job.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml index a053d76a27..b4f02ddec5 100644 --- a/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml +++ b/eng/pipelines/common/templates/jobs/ci-run-tests-job.yml @@ -219,12 +219,14 @@ jobs: operatingSystem: ${{ parameters.operatingSystem }} - ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}: # run x86 tests - - ${{ if and(ne(variables['dotnetx86RootPath'], ''), not(startsWith(parameters.targetFramework, 'net4'))) }}: + - ${{ if ne(variables['dotnetx86RootPath'], '') }}: - template: ../steps/ensure-dotnet-version.yml parameters: - sdk: false - version: ${{ split(replace(parameters.targetFramework, 'net', ''), '.')[0] }} + 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: From ff5b6b7c32f7d13555dc108d3aba029e41e9591a Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 13:07:50 +0100 Subject: [PATCH 25/27] InstallDir --- .../common/templates/steps/ensure-dotnet-version.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index 328f0eee1f..b32f4b6068 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -16,7 +16,7 @@ parameters: - 'arm64' - name: installDir type: string - default: '$(Agent.ToolsDirectory)\dotnet' + default: '' - name: usePreview type: boolean default: false @@ -30,6 +30,12 @@ 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" @@ -56,7 +62,8 @@ steps: ${{ else }}: packageType: runtime version: '${{parameters.version}}.x' - installationPath: '${{parameters.installDir}}' + ${{ if ne(parameters.installDir, '') }}: + installationPath: '${{parameters.installDir}}' includePreviewVersions: ${{parameters.usePreview}} condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) ${{ if eq(parameters.sdk, true) }}: From 918e61dc331958f9d76a8f1a7c450984645b3ad3 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 13:24:04 +0100 Subject: [PATCH 26/27] PS String comparison --- eng/pipelines/common/templates/steps/ensure-dotnet-version.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index b32f4b6068..e44746413c 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -31,7 +31,7 @@ steps: Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile "dotnet-install.ps1" $NEW_DOTNET_ROOT = "${{parameters.installDir}}" - if (${{parameters.installDir}} -eq '') { + if ('${{parameters.installDir}}' -eq '') { $NEW_DOTNET_ROOT = "$(Agent.ToolsDirectory)\dotnet" } else { $NEW_DOTNET_ROOT = "${{parameters.installDir}}" From f0aba78254c81e6d3d895d4987d62af94def2f87 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Wed, 27 Nov 2024 14:03:31 +0100 Subject: [PATCH 27/27] Cosmetics --- .../templates/steps/ensure-dotnet-version.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml index e44746413c..0bee88f8ee 100644 --- a/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml +++ b/eng/pipelines/common/templates/steps/ensure-dotnet-version.yml @@ -1,3 +1,8 @@ +################################################################################# +# 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 @@ -52,9 +57,9 @@ steps: 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 (Windows)" + displayName: "Install .NET ${{parameters.version}} SDK (Win)" ${{ else }}: - displayName: "Install .NET ${{parameters.version}} (Windows)" + displayName: "Install .NET ${{parameters.version}} (Win)" - task: UseDotNet@2 inputs: ${{ if eq(parameters.sdk, true) }}: @@ -67,6 +72,6 @@ steps: includePreviewVersions: ${{parameters.usePreview}} condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) ${{ if eq(parameters.sdk, true) }}: - displayName: "Install .NET ${{parameters.version}} SDK (Other OS)" + displayName: "Install .NET ${{parameters.version}} SDK (non-Win)" ${{ else }}: - displayName: "Install .NET ${{parameters.version}} (Other OS)" \ No newline at end of file + displayName: "Install .NET ${{parameters.version}} (non-Win)" \ No newline at end of file