@@ -55,28 +55,52 @@ function Invoke-WithCreateDefaultHook {
55
55
56
56
function Install-Dotnet {
57
57
param (
58
- $Channel
58
+ [ string []] $Channel
59
59
)
60
60
61
- Write-Host " `n ### Installing .NET CLI $Version ...`n " - ForegroundColor Green
61
+ $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
62
+
63
+ Write-Host " Installing .NET channels $Channel " - ForegroundColor Green
62
64
63
65
# The install script is platform-specific
64
66
$installScriptExt = if ($script :IsUnix ) { " sh" } else { " ps1" }
67
+ $installScript = " dotnet-install.$installScriptExt "
65
68
66
69
# Download the official installation script and run it
67
- $installScriptPath = " $ ( [System.IO.Path ]::GetTempPath()) dotnet-install.$installScriptExt "
68
- Invoke-WebRequest " https://dot.net/v1/dotnet-install.$installScriptExt " - OutFile $installScriptPath
69
- $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
70
+ $installScriptPath = Join-Path ([System.IO.Path ]::GetTempPath()) $installScript
71
+ Invoke-WebRequest " https://dot.net/v1/$installScript " - OutFile $installScriptPath
72
+
73
+ # Download and install the different .NET channels
74
+ foreach ($dotnetChannel in $Channel )
75
+ {
76
+ Write-Host " `n ### Installing .NET CLI $Version ...`n "
77
+
78
+ if ($script :IsUnix ) {
79
+ chmod + x $installScriptPath
80
+ }
81
+
82
+ $params = if ($script :IsUnix )
83
+ {
84
+ @ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
85
+ }
86
+ else
87
+ {
88
+ @ {
89
+ Channel = $dotnetChannel
90
+ InstallDir = $env: DOTNET_INSTALL_DIR
91
+ NoPath = $true
92
+ Verbose = $true
93
+ }
94
+ }
95
+
96
+ & $installScriptPath @params
70
97
71
- if ($script :IsUnix ) {
72
- chmod + x $installScriptPath
98
+ Write-Host " `n ### Installation complete for version $Version ."
73
99
}
74
100
75
- $paramArr = @ (' -Channel' , $Channel , ' -InstallDir' , " '$env: DOTNET_INSTALL_DIR '" , ' -NoPath' )
76
- Invoke-Expression " $installScriptPath $paramArr "
77
101
$env: PATH = $env: DOTNET_INSTALL_DIR + [System.IO.Path ]::PathSeparator + $env: PATH
78
102
79
- Write-Host " `n ### Installation complete. " - ForegroundColor Green
103
+ Write-Host ' .NET installation complete' - ForegroundColor Green
80
104
}
81
105
82
106
task SetupDotNet - Before Clean , Build, TestHost, TestServerWinPS, TestServerPS7, TestServerPS71, TestE2E {
@@ -85,9 +109,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServerWinPS, TestServerPS7,
85
109
$dotnetExePath = if ($script :IsUnix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
86
110
87
111
if (! (Test-Path $dotnetExePath )) {
88
- Install-Dotnet - Channel ' 2.1'
89
- Install-Dotnet - Channel ' 3.1'
90
- Install-Dotnet - Channel ' release/5.0.1xx-preview6'
112
+ Install-Dotnet - Channel ' 2.1' , ' 3.1' , ' release/5.0.1xx-preview6'
91
113
}
92
114
93
115
# This variable is used internally by 'dotnet' to know where it's installed
0 commit comments