1
- Set-StrictMode - Version 2.0
1
+ Set-StrictMode - Version 2.0
2
2
If ($PSVersiontable.PSVersion.Major -le 2 ) {$PSScriptRoot = Split-Path - Parent $MyInvocation.MyCommand.Path }
3
3
Import-Module $PSScriptRoot \OpenSSHCommonUtils.psm1 - Force
4
4
@@ -214,6 +214,12 @@ function Start-OpenSSHBootstrap
214
214
$packageName = " windows-sdk-10.1"
215
215
Write-BuildMsg - AsInfo - Message " $packageName not present. Installing $packageName ..."
216
216
choco install $packageName -- version= $Win10SDKVerChoco - y -- force -- limitoutput -- execution- timeout 120 2>&1 >> $script :BuildLogFile
217
+ # check that sdk was properly installed
218
+ $sdkVersion = Get-Windows10SDKVersion
219
+ if ($sdkVersion -eq $null )
220
+ {
221
+ Write-BuildMsg - AsError - ErrorAction Stop - Message " $packageName installation failed with error code $LASTEXITCODE ."
222
+ }
217
223
}
218
224
219
225
# Using the Win 10 SDK, the x86/x64 builds with VS2015 need vctargetspath to be set.
@@ -223,38 +229,39 @@ function Start-OpenSSHBootstrap
223
229
$env: vctargetspath = " ${env: ProgramFiles(x86)} \MSBuild\Microsoft.Cpp\v4.0\v140"
224
230
if (-not (Test-Path $env: vctargetspath ))
225
231
{
226
- Write-BuildMsg - AsInfo - Message " installing visualcpp-build-tools"
227
- choco install visualcpp- build-tools -- version 14.0 .25420.1 - y -- force -- limitoutput -- execution- timeout 120 2>&1 >> $script :BuildLogFile
232
+ Write-BuildMsg - AsInfo - Message " installing visualcpp-build-tools"
233
+ choco install visualcpp- build-tools -- version 14.0 .25420.1 - y -- force -- limitoutput -- execution- timeout 120 2>&1 >> $script :BuildLogFile
234
+ # check that build-tools were properly installed
235
+ if (-not (Test-Path $env: vctargetspath ))
236
+ {
237
+ Write-BuildMsg - AsError - ErrorAction Stop - Message " $packageName installation failed with error code $LASTEXITCODE ."
238
+ }
228
239
}
229
240
}
230
241
else
231
242
{
232
243
# msbuildtools have a different path for visual studio versions older than 2017
233
244
# for visual studio versions newer than 2017, logic needs to be expanded to update the year in the path accordingly
234
- if ($VS2017Path -ne $null )
245
+ if ($VS2019Path -or $VS2017Path )
235
246
{
236
- $env: vctargetspath = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets"
247
+ $VSPathYear = " 2017"
248
+ if ($VS2019Path )
249
+ {
250
+ $VSPathYear = " 2019"
251
+ }
252
+ $env: vctargetspath = " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\${VSPathYear} \BuildTools\Common7\IDE\VC\VCTargets"
237
253
}
238
254
}
239
255
240
- $sdkPath = " ${env: ProgramFiles(x86)} \Windows Kits\8.1\bin\x86\register_app.vbs"
241
-
242
- if ($VS2019Path -or $VS2017Path )
256
+ # use vs2017 build tool if exists
257
+ if ($VS2019Path -or $VS2017Path )
243
258
{
244
- # Use VS2019 or VS2017 build tools if installed.
245
- if (-not (Test-Path $sdkPath ))
246
- {
247
- $packageName = " windows-sdk-8.1"
248
- Write-BuildMsg - AsInfo - Message " $packageName not present. Installing $packageName ..."
249
- choco install $packageName - y -- force -- limitoutput -- execution- timeout 10000 2>&1 >> $script :BuildLogFile
250
- }
251
-
252
259
if (-not (Test-Path $VcVars ))
253
260
{
254
261
Write-BuildMsg - AsError - ErrorAction Stop - Message " VC++ 2015.3 v140 toolset are not installed."
255
262
}
256
263
}
257
- elseif (! $VS2015Path -or (-not (Test-Path $VcVars )) -or ( -not ( Test-Path $sdkPath )) ) {
264
+ elseif (! $VS2015Path -or (-not (Test-Path $VcVars ))) {
258
265
$packageName = " vcbuildtools"
259
266
Write-BuildMsg - AsInfo - Message " $packageName not present. Installing $packageName ..."
260
267
choco install $packageName - ia " /InstallSelectableItems VisualCppBuildTools_ATLMFC_SDK;VisualCppBuildTools_NETFX_SDK" - y -- force -- limitoutput -- execution- timeout 120 2>&1 >> $script :BuildLogFile
@@ -291,7 +298,7 @@ function Start-OpenSSHBootstrap
291
298
Write-BuildMsg - AsVerbose - Message ' VC++ 2015 Build Tools already present.'
292
299
}
293
300
294
- if ($NativeHostArch.ToLower ().Startswith(' arm' ) -and ( $VS2019Path -or $VS2017Path ) )
301
+ if ($NativeHostArch.ToLower ().Startswith(' arm' ) -and ! $VS2019Path -and ! $VS2017Path )
295
302
{
296
303
# TODO: Install VS2019 or VS2017 build tools
297
304
Write-BuildMsg - AsError - ErrorAction Stop - Message " The required msbuild 15.0 is not installed on the machine."
@@ -305,6 +312,11 @@ function Start-OpenSSHBootstrap
305
312
$packageName = " windows-sdk-10.1"
306
313
Write-BuildMsg - AsInfo - Message " $packageName not present. Installing $packageName ..."
307
314
choco install $packageName -- version= $Win10SDKVerChoco -- force -- limitoutput -- execution- timeout 120 2>&1 >> $script :BuildLogFile
315
+ $win10sdk = Get-Windows10SDKVersion
316
+ if ($win10sdk -eq $null )
317
+ {
318
+ Write-BuildMsg - AsError - ErrorAction Stop - Message " $packageName installation failed with error code $LASTEXITCODE ."
319
+ }
308
320
}
309
321
}
310
322
@@ -654,7 +666,6 @@ function Get-VS2019BuildToolPath
654
666
{
655
667
return $null
656
668
}
657
-
658
669
return $toolAvailable [0 ].FullName
659
670
}
660
671
@@ -672,7 +683,6 @@ function Get-VS2017BuildToolPath
672
683
{
673
684
return $null
674
685
}
675
-
676
686
return $toolAvailable [0 ].FullName
677
687
}
678
688
@@ -689,7 +699,6 @@ function Get-VS2015BuildToolPath
689
699
{
690
700
return $null
691
701
}
692
-
693
702
return $toolAvailable [0 ].FullName
694
703
}
695
704
0 commit comments