@@ -179,53 +179,20 @@ private static BuildScript DownloadDotNetVersion(Autobuilder builder, string pat
179
179
180
180
if ( builder . Actions . IsWindows ( ) )
181
181
{
182
- var psScript = @"param([string]$Version, [string]$InstallDir)
183
182
184
- add-type @""
185
- using System.Net;
186
- using System.Security.Cryptography.X509Certificates;
187
- public class TrustAllCertsPolicy : ICertificatePolicy
188
- {
189
- public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
190
- {
191
- return true;
192
- }
193
- }
194
- ""@
195
- $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
196
- [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
197
- [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
198
- $Script = Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'
199
-
200
- $arguments = @{
201
- Channel = 'release'
202
- Version = $Version
203
- InstallDir = $InstallDir
204
- }
205
-
206
- $ScriptBlock = [scriptblock]::create("".{$($Script)} $(&{$args} @arguments)"")
183
+ var psCommand = $ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version { version } -InstallDir { path } ";
207
184
208
- Invoke-Command -ScriptBlock $ScriptBlock" ;
209
- var psScriptFile = builder . Actions . PathCombine ( builder . Options . RootDirectory , "install-dotnet.ps1" ) ;
210
- builder . Actions . WriteAllText ( psScriptFile , psScript ) ;
211
-
212
- var install = new CommandBuilder ( builder . Actions ) .
213
- RunCommand ( "powershell" ) .
185
+ BuildScript GetInstall ( string pwsh ) =>
186
+ new CommandBuilder ( builder . Actions ) .
187
+ RunCommand ( pwsh ) .
214
188
Argument ( "-NoProfile" ) .
215
189
Argument ( "-ExecutionPolicy" ) .
216
190
Argument ( "unrestricted" ) .
217
- Argument ( "-file" ) .
218
- Argument ( psScriptFile ) .
219
- Argument ( "-Version" ) .
220
- Argument ( version ) .
221
- Argument ( "-InstallDir" ) .
222
- Argument ( path ) ;
223
-
224
- var removeScript = new CommandBuilder ( builder . Actions ) .
225
- RunCommand ( "del" ) .
226
- Argument ( psScriptFile ) ;
191
+ Argument ( "-Command" ) .
192
+ Argument ( "\" " + psCommand + "\" " ) .
193
+ Script ;
227
194
228
- return install . Script & BuildScript . Try ( removeScript . Script ) ;
195
+ return GetInstall ( "pwsh" ) | GetInstall ( "powershell" ) ;
229
196
}
230
197
else
231
198
{
0 commit comments