@@ -57,14 +57,14 @@ $DotNetChannel = 'LTS'
57
57
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
58
58
59
59
[string ] $CakeVersion = ' '
60
- [string ] $DotNetVersion = ' '
60
+ [string [] ] $DotNetVersion = ' '
61
61
foreach ($line in Get-Content (Join-Path $PSScriptRoot ' build.config' ))
62
62
{
63
63
if ($line -like ' CAKE_VERSION=*' ) {
64
64
$CakeVersion = $line.SubString (13 )
65
65
}
66
66
elseif ($line -like ' DOTNET_VERSION=*' ) {
67
- $DotNetVersion = $line.SubString (15 )
67
+ $DotNetVersion = $line.SubString (15 ).Split( ' , ' )
68
68
}
69
69
}
70
70
@@ -110,40 +110,50 @@ Function Remove-PathVariable([string]$VariableToRemove)
110
110
}
111
111
}
112
112
113
- # Get .NET Core CLI path if installed.
114
- $FoundDotNetCliVersion = $null ;
115
- if (Get-Command dotnet - ErrorAction SilentlyContinue) {
116
- $FoundDotNetCliVersion = dotnet -- version;
117
- }
118
-
119
- if ($FoundDotNetCliVersion -ne $DotNetVersion ) {
120
- $InstallPath = Join-Path $PSScriptRoot " .dotnet"
121
- if (! (Test-Path $InstallPath )) {
122
- New-Item - Path $InstallPath - ItemType Directory - Force | Out-Null ;
113
+ Function Add-PathVariable ([string ]$PathToAdd )
114
+ {
115
+ $SplitChar = ' ;'
116
+ if ($IsMacOS -or $IsLinux ) {
117
+ $SplitChar = ' :'
123
118
}
124
119
120
+ $env: PATH = " $ ( $PathToAdd ) $ ( $SplitChar ) $env: PATH "
121
+ }
122
+
123
+ Function Install-Dotnet ($DotNetVersion )
124
+ {
125
125
if ($IsMacOS -or $IsLinux ) {
126
126
$ScriptPath = Join-Path $InstallPath ' dotnet-install.sh'
127
127
(New-Object System.Net.WebClient).DownloadFile($DotNetUnixInstallerUri , $ScriptPath );
128
+
128
129
& bash $ScriptPath -- version " $DotNetVersion " -- install-dir " $InstallPath " -- channel " $DotNetChannel " -- no- path
129
- Remove-PathVariable " $InstallPath "
130
- $env: PATH = " $ ( $InstallPath ) :$env: PATH "
131
130
}
132
131
else {
133
132
$ScriptPath = Join-Path $InstallPath ' dotnet-install.ps1'
134
133
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri , $ScriptPath );
135
- & $ScriptPath - Channel $DotNetChannel - Version $DotNetVersion - InstallDir $InstallPath ;
136
134
137
- Remove-PathVariable " $InstallPath "
138
- $env: PATH = " $InstallPath ;$env: PATH "
135
+ & $ScriptPath - Channel $DotNetChannel - Version $DotNetVersion - InstallDir $InstallPath ;
139
136
}
140
- $env: DOTNET_ROOT = $InstallPath
141
137
}
142
138
139
+ # Get .NET Core CLI path if installed.
140
+ $InstallPath = Join-Path $PSScriptRoot " .dotnet"
141
+ if (! (Test-Path $InstallPath )) {
142
+ New-Item - Path $InstallPath - ItemType Directory - Force | Out-Null ;
143
+ }
144
+
145
+ foreach ($version in $DotNetVersion )
146
+ {
147
+ Install-Dotnet $version
148
+ }
149
+
150
+ Remove-PathVariable " $InstallPath "
151
+ Add-PathVariable " $InstallPath "
152
+ $env: DOTNET_ROOT = $InstallPath
153
+
143
154
$env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
144
155
$env: DOTNET_CLI_TELEMETRY_OPTOUT = 1
145
156
146
-
147
157
# ##########################################################################
148
158
# INSTALL CAKE
149
159
# ##########################################################################
0 commit comments