Skip to content

Commit 991465e

Browse files
authored
merge vs2019 and telemetry build script changes (#545)
1 parent d476258 commit 991465e

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

contrib/win32/openssh/OpenSSHBuildHelper.psm1

+30-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Set-StrictMode -Version 2.0
1+
Set-StrictMode -Version 2.0
22
If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path}
33
Import-Module $PSScriptRoot\OpenSSHCommonUtils.psm1 -Force
44

@@ -214,6 +214,12 @@ function Start-OpenSSHBootstrap
214214
$packageName = "windows-sdk-10.1"
215215
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..."
216216
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+
}
217223
}
218224

219225
# Using the Win 10 SDK, the x86/x64 builds with VS2015 need vctargetspath to be set.
@@ -223,38 +229,39 @@ function Start-OpenSSHBootstrap
223229
$env:vctargetspath = "${env:ProgramFiles(x86)}\MSBuild\Microsoft.Cpp\v4.0\v140"
224230
if (-not (Test-Path $env:vctargetspath))
225231
{
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+
}
228239
}
229240
}
230241
else
231242
{
232243
# msbuildtools have a different path for visual studio versions older than 2017
233244
# 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)
235246
{
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"
237253
}
238254
}
239255

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)
243258
{
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-
252259
if(-not (Test-Path $VcVars))
253260
{
254261
Write-BuildMsg -AsError -ErrorAction Stop -Message "VC++ 2015.3 v140 toolset are not installed."
255262
}
256263
}
257-
elseif (!$VS2015Path -or (-not (Test-Path $VcVars)) -or (-not (Test-Path $sdkPath))) {
264+
elseif (!$VS2015Path -or (-not (Test-Path $VcVars))) {
258265
$packageName = "vcbuildtools"
259266
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..."
260267
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
291298
Write-BuildMsg -AsVerbose -Message 'VC++ 2015 Build Tools already present.'
292299
}
293300

294-
if($NativeHostArch.ToLower().Startswith('arm') -and ($VS2019Path -or $VS2017Path))
301+
if($NativeHostArch.ToLower().Startswith('arm') -and !$VS2019Path -and !$VS2017Path)
295302
{
296303
#TODO: Install VS2019 or VS2017 build tools
297304
Write-BuildMsg -AsError -ErrorAction Stop -Message "The required msbuild 15.0 is not installed on the machine."
@@ -305,6 +312,11 @@ function Start-OpenSSHBootstrap
305312
$packageName = "windows-sdk-10.1"
306313
Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..."
307314
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+
}
308320
}
309321
}
310322

@@ -654,7 +666,6 @@ function Get-VS2019BuildToolPath
654666
{
655667
return $null
656668
}
657-
658669
return $toolAvailable[0].FullName
659670
}
660671

@@ -672,7 +683,6 @@ function Get-VS2017BuildToolPath
672683
{
673684
return $null
674685
}
675-
676686
return $toolAvailable[0].FullName
677687
}
678688

@@ -689,7 +699,6 @@ function Get-VS2015BuildToolPath
689699
{
690700
return $null
691701
}
692-
693702
return $toolAvailable[0].FullName
694703
}
695704

0 commit comments

Comments
 (0)