Skip to content

Commit

Permalink
Allow multiple installations of dotnet. (#17216)
Browse files Browse the repository at this point in the history
* 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.

Co-authored-by: James Truher <jimtru@microsoft.com>
  • Loading branch information
github-actions[bot] and JamesWTruher committed Apr 29, 2022
1 parent 4f25173 commit 8da37f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
33 changes: 21 additions & 12 deletions build.psm1
Expand Up @@ -1737,6 +1737,7 @@ function Install-Dotnet {
[string]$Channel = $dotnetCLIChannel,
[string]$Version = $dotnetCLIRequiredVersion,
[string]$Quality = $dotnetCLIQuality,
[switch]$RemovePreviousVersion,
[switch]$NoSudo,
[string]$InstallDir,
[string]$AzureFeed,
Expand All @@ -1762,20 +1763,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"
}
# 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"
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"
Expand Down Expand Up @@ -1809,6 +1812,8 @@ function Install-Dotnet {
$bashArgs += @('-FeedCredential', $FeedCredential)
}

$bashArgs += @('-skipnonversionedfiles')

$bashArgs | Out-String | Write-Verbose -Verbose

Start-NativeExecution {
Expand Down Expand Up @@ -1841,6 +1846,8 @@ function Install-Dotnet {
$installArgs += @{FeedCredential = $FeedCredential}
}

$installArgs += @{ SkipNonVersionedFiles = $true }

$installArgs | Out-String | Write-Verbose -Verbose

& ./$installScript @installArgs
Expand Down Expand Up @@ -1869,6 +1876,8 @@ function Install-Dotnet {
$psArgs += @('-FeedCredential', $FeedCredential)
}

$psArgs += @('-SkipNonVersionedFiles')

$psArgs | Out-String | Write-Verbose -Verbose

Start-NativeExecution {
Expand Down
4 changes: 2 additions & 2 deletions tools/cgmanifest.json
Expand Up @@ -215,7 +215,7 @@
"Type": "nuget",
"Nuget": {
"Name": "Microsoft.Win32.SystemEvents",
"Version": "6.0.0"
"Version": "6.0.1"
}
},
"DevelopmentDependency": false
Expand Down Expand Up @@ -825,7 +825,7 @@
"Type": "nuget",
"Nuget": {
"Name": "System.Diagnostics.PerformanceCounter",
"Version": "6.0.0"
"Version": "6.0.1"
}
},
"DevelopmentDependency": false
Expand Down

0 comments on commit 8da37f9

Please sign in to comment.