@@ -52,12 +52,16 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
5252
5353function Install-Dotnet {
5454 param (
55- [string []]$Channel
55+ [string []]$Channel ,
56+ [switch ]$Runtime
5657 )
5758
5859 $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
5960
60- Write-Host " Installing .NET channels $Channel " - ForegroundColor Green
61+ $components = if ($Runtime ) { " Runtime " } else { " SDK and Runtime " }
62+ $components += $Channel -join ' , '
63+
64+ Write-Host " Installing .NET $components " - ForegroundColor Green
6165
6266 # The install script is platform-specific
6367 $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
@@ -70,18 +74,13 @@ function Install-Dotnet {
7074 # Download and install the different .NET channels
7175 foreach ($dotnetChannel in $Channel )
7276 {
73- Write-Host " `n ### Installing .NET CLI $Version ...`n "
74-
7577 if ($script :IsNix ) {
7678 chmod + x $installScriptPath
7779 }
7880
79- $params = if ($script :IsNix )
80- {
81+ $params = if ($script :IsNix ) {
8182 @ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
82- }
83- else
84- {
83+ } else {
8584 @ {
8685 Channel = $dotnetChannel
8786 InstallDir = $env: DOTNET_INSTALL_DIR
@@ -90,9 +89,13 @@ function Install-Dotnet {
9089 }
9190 }
9291
93- & $installScriptPath @params
92+ # Install just the runtime, not the SDK
93+ if ($Runtime ) {
94+ if ($script :IsNix ) { $params += @ (' -Runtime' , ' dotnet' ) }
95+ else { $params [' Runtime' ] = ' dotnet' }
96+ }
9497
95- Write-Host " `n ### Installation complete for version $Version . "
98+ exec { & $installScriptPath @params }
9699 }
97100
98101 $env: PATH = $env: DOTNET_INSTALL_DIR + [System.IO.Path ]::PathSeparator + $env: PATH
@@ -107,7 +110,8 @@ task SetupDotNet -Before Clean, Build, TestServerWinPS, TestServerPS7, TestServe
107110
108111 if (! (Test-Path $dotnetExePath )) {
109112 # TODO: Test .NET 5 with PowerShell 7.1
110- Install-Dotnet - Channel ' 3.1' , ' 5.0' , ' 6.0'
113+ Install-Dotnet - Channel ' 6.0' # SDK and runtime
114+ Install-Dotnet - Channel ' 3.1' , ' 5.0' - Runtime # Runtime only
111115 }
112116
113117 # This variable is used internally by 'dotnet' to know where it's installed
0 commit comments