From 0b78239f2ec4827f266cd16614b79750033dab1d Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 18 Sep 2025 17:16:55 -0700 Subject: [PATCH 1/3] Install dotnet using script --- .pipelines/templates/install-dotnet.yml | 14 ++++ .pipelines/templates/linux.yml | 7 +- .pipelines/templates/mac.yml | 8 +- .pipelines/templates/nupkg.yml | 7 +- .pipelines/templates/testartifacts.yml | 32 ++++---- .pipelines/templates/windows-hosted-build.yml | 11 ++- .../templates/windows-package-build.yml | 7 +- build.psm1 | 75 +++++-------------- 8 files changed, 59 insertions(+), 102 deletions(-) create mode 100644 .pipelines/templates/install-dotnet.yml diff --git a/.pipelines/templates/install-dotnet.yml b/.pipelines/templates/install-dotnet.yml new file mode 100644 index 00000000000..40e7e1c7ef9 --- /dev/null +++ b/.pipelines/templates/install-dotnet.yml @@ -0,0 +1,14 @@ +steps: + - pwsh: | + $version = Get-Content ./global.json | ConvertFrom-Json | Select-Object -ExpandProperty sdk | Select-Object -ExpandProperty version + + Write-Verbose -Verbose "Installing .NET SDK with version $version" + + Import-Module ./build.psm1 -Force + Install-Dotnet -Version $version -Verbose + + displayName: 'Install dotnet SDK' + workingDirectory: $(PowerShellRoot) + env: + ob_restore_phase: true + diff --git a/.pipelines/templates/linux.yml b/.pipelines/templates/linux.yml index 83b7aa58ef3..aef0b53381f 100644 --- a/.pipelines/templates/linux.yml +++ b/.pipelines/templates/linux.yml @@ -64,12 +64,7 @@ jobs: AnalyzeInPipeline: false Language: csharp - - task: UseDotNet@2 - inputs: - useGlobalJson: true - workingDirectory: $(PowerShellRoot) - env: - ob_restore_phase: true + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $runtime = $env:RUNTIME diff --git a/.pipelines/templates/mac.yml b/.pipelines/templates/mac.yml index b08becedc22..ff4787b9bcf 100644 --- a/.pipelines/templates/mac.yml +++ b/.pipelines/templates/mac.yml @@ -39,12 +39,8 @@ jobs: sudo chown $env:USER "$(Agent.TempDirectory)/PowerShell" displayName: 'Create $(Agent.TempDirectory)/PowerShell' - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(PowerShellRoot) + ## We cross compile for arm64, so the arch is always x64 + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | Import-Module $(PowerShellRoot)/build.psm1 -Force diff --git a/.pipelines/templates/nupkg.yml b/.pipelines/templates/nupkg.yml index dc43e841332..3002881de86 100644 --- a/.pipelines/templates/nupkg.yml +++ b/.pipelines/templates/nupkg.yml @@ -97,12 +97,7 @@ jobs: - task: NuGetToolInstaller@1 displayName: 'Install NuGet.exe' - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: '$(PowerShellRoot)' + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | Set-Location -Path '$(PowerShellRoot)' diff --git a/.pipelines/templates/testartifacts.yml b/.pipelines/templates/testartifacts.yml index 240ceae80f7..ee7efcc88eb 100644 --- a/.pipelines/templates/testartifacts.yml +++ b/.pipelines/templates/testartifacts.yml @@ -25,19 +25,18 @@ jobs: env: ob_restore_phase: true + - template: /.pipelines/templates/SetVersionVariables.yml@self + parameters: + ReleaseTagVar: $(ReleaseTagVar) + + - template: /.pipelines/templates/cloneToOfficialPath.yml@self + - template: /.pipelines/templates/insert-nuget-config-azfeed.yml@self parameters: - repoRoot: $(Build.SourcesDirectory)/PowerShell + repoRoot: $(PowerShellRoot) ob_restore_phase: true - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(Build.SourcesDirectory)/PowerShell" - env: - ob_restore_phase: true + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | New-Item -Path '$(ob_outputDirectory)' -ItemType Directory -Force @@ -93,19 +92,18 @@ jobs: env: ob_restore_phase: true + - template: /.pipelines/templates/SetVersionVariables.yml@self + parameters: + ReleaseTagVar: $(ReleaseTagVar) + + - template: /.pipelines/templates/cloneToOfficialPath.yml@self + - template: /.pipelines/templates/insert-nuget-config-azfeed.yml@self parameters: repoRoot: $(Build.SourcesDirectory)/PowerShell ob_restore_phase: true - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(Build.SourcesDirectory)/PowerShell" - env: - ob_restore_phase: true + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | New-Item -Path '$(ob_outputDirectory)' -ItemType Directory -Force diff --git a/.pipelines/templates/windows-hosted-build.yml b/.pipelines/templates/windows-hosted-build.yml index 8cd622149fa..4472744d7b5 100644 --- a/.pipelines/templates/windows-hosted-build.yml +++ b/.pipelines/templates/windows-hosted-build.yml @@ -65,12 +65,7 @@ jobs: AnalyzeInPipeline: false Language: csharp - - task: UseDotNet@2 - inputs: - useGlobalJson: true - workingDirectory: $(PowerShellRoot) - env: - ob_restore_phase: true + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $runtime = switch ($env:Architecture) @@ -144,6 +139,7 @@ jobs: } Import-Module -Name $(PowerShellRoot)/build.psm1 -Force + Find-Dotnet ## Build global tool Write-Verbose -Message "Building PowerShell global tool for Windows.x64" -Verbose @@ -239,6 +235,9 @@ jobs: After that, we repack using Compress-Archive and rename it back to a nupkg. #> + Import-Module -Name $(PowerShellRoot)/build.psm1 -Force + Find-Dotnet + $packagingStrings = Import-PowerShellDataFile "$(PowerShellRoot)\tools\packaging\packaging.strings.psd1" $outputPath = Join-Path '$(ob_outputDirectory)' 'globaltool' diff --git a/.pipelines/templates/windows-package-build.yml b/.pipelines/templates/windows-package-build.yml index 7cd0869caa0..612ef1f9bbd 100644 --- a/.pipelines/templates/windows-package-build.yml +++ b/.pipelines/templates/windows-package-build.yml @@ -78,12 +78,7 @@ jobs: env: ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue - - task: UseDotNet@2 - inputs: - useGlobalJson: true - workingDirectory: $(REPOROOT) - env: - ob_restore_phase: true + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $msixUrl = '$(makeappUrl)' diff --git a/build.psm1 b/build.psm1 index ffbeddb1c21..a75b4b8577a 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2092,8 +2092,8 @@ function Install-Dotnet { # Note that when it is null, Invoke-Expression (but not &) must be used to interpolate properly $sudo = if (!$NoSudo) { "sudo" } - # $installObtainUrl = "https://dot.net/v1" - $installObtainUrl = "https://dotnet.microsoft.com/download/dotnet/scripts/v1" + $installObtainUrl = "https://builds.dotnet.microsoft.com/dotnet/scripts/v1" + #$installObtainUrl = "https://dotnet.microsoft.com/download/dotnet/scripts/v1" $uninstallObtainUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain" # Install for Linux and OS X @@ -2160,66 +2160,31 @@ function Install-Dotnet { Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet $installScript = "dotnet-install.ps1" Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript - if (-not $environment.IsCoreCLR) { - $installArgs = @{} - if ($Version) { - $installArgs += @{ Version = $Version } - } elseif ($Channel) { - $installArgs += @{ Quality = $Quality } - $installArgs += @{ Channel = $Channel } - } - - if ($InstallDir) { - $installArgs += @{ InstallDir = $InstallDir } - } - - if ($AzureFeed) { - $installArgs += @{AzureFeed = $AzureFeed} - } - if ($FeedCredential) { - $installArgs += @{FeedCredential = $FeedCredential} - } - - $installArgs += @{ SkipNonVersionedFiles = $true } - - $installArgs | Out-String | Write-Verbose -Verbose - - & ./$installScript @installArgs + $installArgs = @{} + if ($Version) { + $installArgs += @{ Version = $Version } + } elseif ($Channel) { + $installArgs += @{ Quality = $Quality } + $installArgs += @{ Channel = $Channel } } - else { - # dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell - $fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe" - $fullDotnetInstallPath = Join-Path -Path (Convert-Path -Path $PWD.Path) -ChildPath $installScript - if ($Version) { - $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version) - } - elseif ($Channel) { - $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality) - } - - if ($InstallDir) { - $psArgs += @('-InstallDir', $InstallDir) - } - - if ($AzureFeed) { - $psArgs += @('-AzureFeed', $AzureFeed) - } + if ($InstallDir) { + $installArgs += @{ InstallDir = $InstallDir } + } - if ($FeedCredential) { - $psArgs += @('-FeedCredential', $FeedCredential) - } + if ($AzureFeed) { + $installArgs += @{AzureFeed = $AzureFeed} + } - $psArgs += @('-SkipNonVersionedFiles') + if ($FeedCredential) { + $installArgs += @{FeedCredential = $FeedCredential} + } - # Removing the verbose message to not expose the secret - # $psArgs -join ' ' | Write-Verbose -Verbose + $installArgs += @{ SkipNonVersionedFiles = $true } - Start-NativeExecution { - & $fullPSPath @psArgs - } - } + $installArgs | Out-String | Write-Verbose -Verbose + & ./$installScript @installArgs } } From f0a3d9d7199b7bf0d96e93de3cd6449c31c818e1 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 25 Sep 2025 10:42:22 -0700 Subject: [PATCH 2/3] Add disable network isolation parameter --- .pipelines/PowerShell-Packages-Official.yml | 6 ++++++ .pipelines/templates/install-dotnet.yml | 7 +++++++ .pipelines/templates/linux-package-build.yml | 2 ++ .pipelines/templates/nupkg.yml | 4 ++-- .pipelines/templates/windows-package-build.yml | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.pipelines/PowerShell-Packages-Official.yml b/.pipelines/PowerShell-Packages-Official.yml index 552e7d10a68..9c2dee1c571 100644 --- a/.pipelines/PowerShell-Packages-Official.yml +++ b/.pipelines/PowerShell-Packages-Official.yml @@ -27,6 +27,9 @@ parameters: # parameters are shown up in ADO UI in a build queue time - name: OfficialBuild type: boolean default: false + - name: disableNetworkIsolation + type: boolean + default: false name: pkgs-$(BUILD.SOURCEBRANCHNAME)-prod.${{ parameters.OfficialBuild }}-$(Build.BuildId) @@ -66,6 +69,8 @@ variables: - group: MSIXSigningProfile - name: templateFile value: ${{ iif ( parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@onebranchTemplates' ) }} + - name: disableNetworkIsolation + value: ${{ parameters.disableNetworkIsolation }} resources: pipelines: @@ -96,6 +101,7 @@ extends: Network: KS3 linuxEsrpSigning: true incrementalSDLBinaryAnalysis: true + disableNetworkIsolation: ${{ variables.disableNetworkIsolation }} globalSdl: disableLegacyManifest: true # disabled Armorty as we dont have any ARM templates to scan. It fails on some sample ARM templates. diff --git a/.pipelines/templates/install-dotnet.yml b/.pipelines/templates/install-dotnet.yml index 40e7e1c7ef9..0eac5218f7c 100644 --- a/.pipelines/templates/install-dotnet.yml +++ b/.pipelines/templates/install-dotnet.yml @@ -1,5 +1,12 @@ steps: - pwsh: | + $psRoot = '$(PowerShellRoot)' + + if (-not (Test-Path $psRoot)) { + $psRoot = '$(Build.SourcesDirectory)/PowerShell' + Set-Location $psRoot -Verbose + } + $version = Get-Content ./global.json | ConvertFrom-Json | Select-Object -ExpandProperty sdk | Select-Object -ExpandProperty version Write-Verbose -Verbose "Installing .NET SDK with version $version" diff --git a/.pipelines/templates/linux-package-build.yml b/.pipelines/templates/linux-package-build.yml index 95996a597fe..cd4920dabc6 100644 --- a/.pipelines/templates/linux-package-build.yml +++ b/.pipelines/templates/linux-package-build.yml @@ -87,6 +87,8 @@ jobs: env: ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue + - template: /.pipelines/templates/install-dotnet.yml@self + - pwsh: | $packageType = '$(PackageType)' Write-Verbose -Verbose "packageType = $packageType" diff --git a/.pipelines/templates/nupkg.yml b/.pipelines/templates/nupkg.yml index 3002881de86..d2091532693 100644 --- a/.pipelines/templates/nupkg.yml +++ b/.pipelines/templates/nupkg.yml @@ -94,8 +94,8 @@ jobs: parameters: repoRoot: $(PowerShellRoot) - - task: NuGetToolInstaller@1 - displayName: 'Install NuGet.exe' + # - task: NuGetToolInstaller@1 + # displayName: 'Install NuGet.exe' - template: /.pipelines/templates/install-dotnet.yml@self diff --git a/.pipelines/templates/windows-package-build.yml b/.pipelines/templates/windows-package-build.yml index 612ef1f9bbd..2ae429047ac 100644 --- a/.pipelines/templates/windows-package-build.yml +++ b/.pipelines/templates/windows-package-build.yml @@ -109,6 +109,8 @@ jobs: Start-PSBootstrap -Scenario Package + Find-Dotnet + $signedFilesPath, $psoptionsFilePath = if ($env:RUNTIME -eq 'minsize') { "$(Pipeline.Workspace)\CoOrdinatedBuildPipeline\drop_windows_build_windows_x64_${runtime}\$signedFolder" "$(Pipeline.Workspace)\CoOrdinatedBuildPipeline\drop_windows_build_windows_x64_${runtime}\psoptions\psoptions.json" From ff1ce576127a89f973ea6a0b0a93551be40b4826 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 25 Sep 2025 14:27:25 -0700 Subject: [PATCH 3/3] Update ymls for rlease --- .pipelines/templates/install-dotnet.yml | 6 +- .pipelines/templates/linux-package-build.yml | 2 +- .pipelines/templates/nupkg.yml | 3 - .../release-validate-fxdpackages.yml | 7 +- .../release-validate-globaltools.yml | 7 +- .pipelines/templates/release-validate-sdk.yml | 7 +- .pipelines/templates/testartifacts.yml | 6 +- .../templates/windows-package-build.yml | 2 +- build.psm1 | 70 ++++++++++++++----- 9 files changed, 60 insertions(+), 50 deletions(-) diff --git a/.pipelines/templates/install-dotnet.yml b/.pipelines/templates/install-dotnet.yml index 0eac5218f7c..c2a2cfebeca 100644 --- a/.pipelines/templates/install-dotnet.yml +++ b/.pipelines/templates/install-dotnet.yml @@ -1,8 +1,6 @@ steps: - pwsh: | - $psRoot = '$(PowerShellRoot)' - - if (-not (Test-Path $psRoot)) { + if (-not (Test-Path '$(RepoRoot)')) { $psRoot = '$(Build.SourcesDirectory)/PowerShell' Set-Location $psRoot -Verbose } @@ -15,7 +13,7 @@ steps: Install-Dotnet -Version $version -Verbose displayName: 'Install dotnet SDK' - workingDirectory: $(PowerShellRoot) + workingDirectory: $(RepoRoot) env: ob_restore_phase: true diff --git a/.pipelines/templates/linux-package-build.yml b/.pipelines/templates/linux-package-build.yml index cd4920dabc6..68fa46690c2 100644 --- a/.pipelines/templates/linux-package-build.yml +++ b/.pipelines/templates/linux-package-build.yml @@ -105,7 +105,7 @@ jobs: Import-Module "$repoRoot/build.psm1" Import-Module "$repoRoot/tools/packaging" - Start-PSBootstrap -Scenario Package + Start-PSBootstrap -Scenario Both $psOptionsPath = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/${unsignedDrop}/psoptions/psoptions.json" diff --git a/.pipelines/templates/nupkg.yml b/.pipelines/templates/nupkg.yml index d2091532693..4756c99a9d3 100644 --- a/.pipelines/templates/nupkg.yml +++ b/.pipelines/templates/nupkg.yml @@ -94,9 +94,6 @@ jobs: parameters: repoRoot: $(PowerShellRoot) - # - task: NuGetToolInstaller@1 - # displayName: 'Install NuGet.exe' - - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | diff --git a/.pipelines/templates/release-validate-fxdpackages.yml b/.pipelines/templates/release-validate-fxdpackages.yml index 9de8c7dad33..3f4f9a3bb6c 100644 --- a/.pipelines/templates/release-validate-fxdpackages.yml +++ b/.pipelines/templates/release-validate-fxdpackages.yml @@ -61,12 +61,7 @@ jobs: Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/$artifactName" -Recurse displayName: 'Capture Downloaded Artifacts' - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(Build.SourcesDirectory)/PowerShell" + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $artifactName = '$(artifactName)' diff --git a/.pipelines/templates/release-validate-globaltools.yml b/.pipelines/templates/release-validate-globaltools.yml index 3dd1fd15f56..4a7d23c8b4b 100644 --- a/.pipelines/templates/release-validate-globaltools.yml +++ b/.pipelines/templates/release-validate-globaltools.yml @@ -38,12 +38,7 @@ jobs: Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse displayName: 'Capture Downloaded Artifacts' - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(REPOROOT) + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $repoRoot = "$(Build.SourcesDirectory)/PowerShell" diff --git a/.pipelines/templates/release-validate-sdk.yml b/.pipelines/templates/release-validate-sdk.yml index cdd818f9dc2..4089d54e51b 100644 --- a/.pipelines/templates/release-validate-sdk.yml +++ b/.pipelines/templates/release-validate-sdk.yml @@ -46,12 +46,7 @@ jobs: Get-ChildItem "$(Pipeline.Workspace)/PSPackagesOfficial/drop_nupkg_build_nupkg" -Recurse displayName: 'Capture Downloaded Artifacts' - - task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - useGlobalJson: true - packageType: 'sdk' - workingDirectory: $(REPOROOT) + - template: /.pipelines/templates/install-dotnet.yml@self - pwsh: | $repoRoot = "$(Build.SourcesDirectory)" diff --git a/.pipelines/templates/testartifacts.yml b/.pipelines/templates/testartifacts.yml index ee7efcc88eb..751c9d5a53b 100644 --- a/.pipelines/templates/testartifacts.yml +++ b/.pipelines/templates/testartifacts.yml @@ -29,11 +29,9 @@ jobs: parameters: ReleaseTagVar: $(ReleaseTagVar) - - template: /.pipelines/templates/cloneToOfficialPath.yml@self - - template: /.pipelines/templates/insert-nuget-config-azfeed.yml@self parameters: - repoRoot: $(PowerShellRoot) + repoRoot: $(RepoRoot) ob_restore_phase: true - template: /.pipelines/templates/install-dotnet.yml@self @@ -96,8 +94,6 @@ jobs: parameters: ReleaseTagVar: $(ReleaseTagVar) - - template: /.pipelines/templates/cloneToOfficialPath.yml@self - - template: /.pipelines/templates/insert-nuget-config-azfeed.yml@self parameters: repoRoot: $(Build.SourcesDirectory)/PowerShell diff --git a/.pipelines/templates/windows-package-build.yml b/.pipelines/templates/windows-package-build.yml index 2ae429047ac..bc23bfc659e 100644 --- a/.pipelines/templates/windows-package-build.yml +++ b/.pipelines/templates/windows-package-build.yml @@ -107,7 +107,7 @@ jobs: Import-Module "$repoRoot\build.psm1" Import-Module "$repoRoot\tools\packaging" - Start-PSBootstrap -Scenario Package + Start-PSBootstrap -Scenario Both Find-Dotnet diff --git a/build.psm1 b/build.psm1 index a75b4b8577a..a610c684e2c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2160,31 +2160,65 @@ function Install-Dotnet { Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet $installScript = "dotnet-install.ps1" Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript + if (-not $environment.IsCoreCLR) { + $installArgs = @{} + if ($Version) { + $installArgs += @{ Version = $Version } + } elseif ($Channel) { + $installArgs += @{ Quality = $Quality } + $installArgs += @{ Channel = $Channel } + } - $installArgs = @{} - if ($Version) { - $installArgs += @{ Version = $Version } - } elseif ($Channel) { - $installArgs += @{ Quality = $Quality } - $installArgs += @{ Channel = $Channel } - } + if ($InstallDir) { + $installArgs += @{ InstallDir = $InstallDir } + } - if ($InstallDir) { - $installArgs += @{ InstallDir = $InstallDir } - } + if ($AzureFeed) { + $installArgs += @{AzureFeed = $AzureFeed} + } - if ($AzureFeed) { - $installArgs += @{AzureFeed = $AzureFeed} - } + if ($FeedCredential) { + $installArgs += @{FeedCredential = $FeedCredential} + } + + $installArgs += @{ SkipNonVersionedFiles = $true } - if ($FeedCredential) { - $installArgs += @{FeedCredential = $FeedCredential} + $installArgs | Out-String | Write-Verbose -Verbose + & ./$installScript @installArgs } + else { + # dotnet-install.ps1 uses APIs that are not supported in .NET Core, so we run it with Windows PowerShell + $fullPSPath = Join-Path -Path $env:windir -ChildPath "System32\WindowsPowerShell\v1.0\powershell.exe" + $fullDotnetInstallPath = Join-Path -Path (Convert-Path -Path $PWD.Path) -ChildPath $installScript + + if ($Version) { + $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Version', $Version) + } + elseif ($Channel) { + $psArgs = @('-NoLogo', '-NoProfile', '-File', $fullDotnetInstallPath, '-Channel', $Channel, '-Quality', $Quality) + } + + if ($InstallDir) { + $psArgs += @('-InstallDir', $InstallDir) + } - $installArgs += @{ SkipNonVersionedFiles = $true } + if ($AzureFeed) { + $psArgs += @('-AzureFeed', $AzureFeed) + } - $installArgs | Out-String | Write-Verbose -Verbose - & ./$installScript @installArgs + if ($FeedCredential) { + $psArgs += @('-FeedCredential', $FeedCredential) + } + + $psArgs += @('-SkipNonVersionedFiles') + + # Removing the verbose message to not expose the secret + # $psArgs -join ' ' | Write-Verbose -Verbose + + Start-NativeExecution { + & $fullPSPath @psArgs + } + } } }