From 9c13c0494fbedd50b1752c322ededd27ee2568de Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Tue, 12 Apr 2022 14:26:52 -0700 Subject: [PATCH] Allow multiple installations of dotnet. (#17141) * Allow multiple installations of dotnet. A new flag for removal is now provided, but by default we will add a new version of dotnet. * Add updated CG manifest. --- build.psm1 | 35 ++++++++++++++++++++++------------- tools/cgmanifest.json | 6 +++--- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/build.psm1 b/build.psm1 index b20aa6ad17..89714cc2df 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1801,6 +1801,7 @@ function Install-Dotnet { [string]$Channel = $dotnetCLIChannel, [string]$Version = $dotnetCLIRequiredVersion, [string]$Quality = $dotnetCLIQuality, + [switch]$RemovePreviousVersion, [switch]$NoSudo, [string]$InstallDir, [string]$AzureFeed, @@ -1821,20 +1822,22 @@ function Install-Dotnet { if ($environment.IsLinux -or $environment.IsMacOS) { $wget = Get-Command -Name wget -CommandType Application -TotalCount 1 -ErrorAction Stop - # Uninstall all previous dotnet packages - $uninstallScript = if ($environment.IsLinux -and $environment.IsUbuntu) { - "dotnet-uninstall-debian-packages.sh" - } elseif ($environment.IsMacOS) { - "dotnet-uninstall-pkgs.sh" - } - - if ($uninstallScript) { - Start-NativeExecution { - & $wget $uninstallObtainUrl/uninstall/$uninstallScript - Invoke-Expression "$sudo bash ./$uninstallScript" + # Attempt to uninstall previous dotnet packages if requested + if ($RemovePreviousVersion) { + $uninstallScript = if ($environment.IsLinux -and $environment.IsUbuntu) { + "dotnet-uninstall-debian-packages.sh" + } elseif ($environment.IsMacOS) { + "dotnet-uninstall-pkgs.sh" + } + + if ($uninstallScript) { + Start-NativeExecution { + & $wget $uninstallObtainUrl/uninstall/$uninstallScript + Invoke-Expression "$sudo bash ./$uninstallScript" + } + } else { + Write-Warning "This script only removes prior versions of dotnet for Ubuntu and OS X" } - } else { - Write-Warning "This script only removes prior versions of dotnet for Ubuntu and OS X" } Write-Verbose -Verbose "Invoking install script" @@ -1868,6 +1871,8 @@ function Install-Dotnet { $bashArgs += @('-FeedCredential', $FeedCredential) } + $bashArgs += @('-skipnonversionedfiles') + $bashArgs | Out-String | Write-Verbose -Verbose Start-NativeExecution { @@ -1898,6 +1903,8 @@ function Install-Dotnet { $installArgs += @{FeedCredential = $FeedCredential} } + $installArgs += @{ SkipNonVersionedFiles = $true } + $installArgs | Out-String | Write-Verbose -Verbose & ./$installScript @installArgs @@ -1926,6 +1933,8 @@ function Install-Dotnet { $psArgs += @('-FeedCredential', $FeedCredential) } + $psArgs += @('-SkipNonVersionedFiles') + $psArgs | Out-String | Write-Verbose -Verbose Start-NativeExecution { diff --git a/tools/cgmanifest.json b/tools/cgmanifest.json index 11b27afff6..21e6016472 100644 --- a/tools/cgmanifest.json +++ b/tools/cgmanifest.json @@ -215,7 +215,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.Win32.SystemEvents", - "Version": "6.0.0" + "Version": "6.0.1" } }, "DevelopmentDependency": false @@ -825,7 +825,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Diagnostics.PerformanceCounter", - "Version": "6.0.0" + "Version": "6.0.1" } }, "DevelopmentDependency": false @@ -975,7 +975,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Net.Http.WinHttpHandler", - "Version": "6.0.0" + "Version": "6.0.1" } }, "DevelopmentDependency": false