From a5436319aae68722b14586856beaa58ba4d9af39 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Sat, 8 May 2021 10:21:31 -0700 Subject: [PATCH 1/4] Fix build script to work with VS2019 --- contrib/win32/openssh/OpenSSHBuildHelper.psm1 | 75 +++++++++++++++---- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 b/contrib/win32/openssh/OpenSSHBuildHelper.psm1 index 52440544962..bf2e9083cfa 100644 --- a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 +++ b/contrib/win32/openssh/OpenSSHBuildHelper.psm1 @@ -1,4 +1,4 @@ -Set-StrictMode -Version 2.0 +Set-StrictMode -Version 2.0 If ($PSVersiontable.PSVersion.Major -le 2) {$PSScriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path} Import-Module $PSScriptRoot\OpenSSHCommonUtils.psm1 -Force @@ -196,8 +196,9 @@ function Start-OpenSSHBootstrap Write-BuildMsg -AsVerbose -Message "$gitCmdPath already present in Path environment variable" -Silent:$silent } - $VS2015Path = Get-VS2015BuildToolPath + $VS2019Path = Get-VS2019BuildToolPath $VS2017Path = Get-VS2017BuildToolPath + $VS2015Path = Get-VS2015BuildToolPath # Update machine environment path if ($newMachineEnvironmentPath -ne $machinePath) @@ -236,17 +237,24 @@ function Start-OpenSSHBootstrap } } - #use vs2017 build tool if exists - if($VS2017Path -ne $null) - { + $sdkPath = "${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x86\register_app.vbs" + if ($VS2019Path -or $VS2017Path) + { + # Use VS2019 or VS2017 build tools if installed. + if (-not (Test-Path $sdkPath)) + { + $packageName = "windows-sdk-8.1" + Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..." + choco install $packageName -y --force --limitoutput --execution-timeout 10000 2>&1 >> $script:BuildLogFile + } if(-not (Test-Path $VcVars)) { Write-BuildMsg -AsError -ErrorAction Stop -Message "VC++ 2015.3 v140 toolset are not installed." } } - elseIf (($VS2015Path -eq $null) -or (-not (Test-Path $VcVars))) { + elseIf (($VS2015Path -eq $null) -or (-not (Test-Path $VcVars)) -or (-not (Test-Path $sdkPath))) { $packageName = "vcbuildtools" Write-BuildMsg -AsInfo -Message "$packageName not present. Installing $packageName ..." choco install $packageName -ia "/InstallSelectableItems VisualCppBuildTools_ATLMFC_SDK;VisualCppBuildTools_NETFX_SDK" -y --force --limitoutput --execution-timeout 120 2>&1 >> $script:BuildLogFile @@ -283,10 +291,9 @@ function Start-OpenSSHBootstrap Write-BuildMsg -AsVerbose -Message 'VC++ 2015 Build Tools already present.' } - if($NativeHostArch.ToLower().Startswith('arm') -and ($VS2017Path -eq $null)) + if($NativeHostArch.ToLower().Startswith('arm') -and ($VS2019Path -or $VS2017Path)) { - - #todo, install vs 2017 build tools + #TODO: Install VS2019 or VS2017 build tools Write-BuildMsg -AsError -ErrorAction Stop -Message "The required msbuild 15.0 is not installed on the machine." } @@ -302,9 +309,16 @@ function Start-OpenSSHBootstrap } # Ensure the VS C toolset is installed - if ($null -eq $env:VS140COMNTOOLS) + if (!$env:VS140COMNTOOLS) { - Write-BuildMsg -AsError -ErrorAction Stop -Message "Cannot find Visual Studio 2015 Environment variable VS140COMNTOOlS." + if (Test-Path $vcVars) + { + $env:VS140COMNTOOLS = Split-Path $vcVars + } + else + { + Write-BuildMsg -AsError -ErrorAction Stop -Message "Cannot find Visual Studio 2015 Environment variable VS140COMNTOOlS." + } } $item = Get-Item(Join-Path -Path $env:VS140COMNTOOLS -ChildPath '../../vc') @@ -594,13 +608,24 @@ function Start-OpenSSHBuild { $cmdMsg += "/noconlog" } - - $msbuildCmd = Get-VS2017BuildToolPath - if($msbuildCmd -eq $null) + + if ($msbuildCmd = Get-VS2019BuildToolPath) { - $msbuildCmd = Get-VS2015BuildToolPath + Write-BuildMsg -AsInfo -Message "Using MSBuild path: $msbuildCmd" } - + elseif ($msbuildCmd = Get-VS2017BuildToolPath) + { + Write-BuildMsg -AsInfo -Message "Using MSBuild path: $msbuildCmd" + } + elseif ($msbuildCmd = Get-VS2015BuildToolPath) + { + Write-BuildMsg -AsInfo -Message "Using MSBuild path: $msbuildCmd" + } + else + { + Write-BuildMsg -AsError -ErrorAction Stop -Message "MSBuild not found" + } + Write-BuildMsg -AsInfo -Message "Starting Open SSH build; Build Log: $($script:BuildLogFile)." Write-BuildMsg -AsInfo -Message "$msbuildCmd $cmdMsg" @@ -615,8 +640,26 @@ function Start-OpenSSHBuild Write-BuildMsg -AsInfo -Message "SSH build successful." } +function Get-VS2019BuildToolPath +{ + # TODO: Should use vswhere: https://github.com/microsoft/vswhere/wiki/Find-MSBuild + $searchPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\*\MSBuild\Current\Bin" + if($env:PROCESSOR_ARCHITECTURE -ieq "AMD64") + { + $searchPath += "\amd64" + } + $toolAvailable = @() + $toolAvailable += Get-ChildItem -path $searchPath\* -Filter "MSBuild.exe" -ErrorAction SilentlyContinue + if($toolAvailable.count -eq 0) + { + return $null + } + return $toolAvailable[0].FullName +} + function Get-VS2017BuildToolPath { + # TODO: Should use vswhere: https://github.com/microsoft/vswhere/wiki/Find-MSBuild $searchPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\*\MSBuild\15.0\Bin" if($env:PROCESSOR_ARCHITECTURE -ieq "AMD64") { From b28b9006c3bfb9e97ee478d4b0f80a782e989a57 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Sun, 25 Jul 2021 22:25:33 -0700 Subject: [PATCH 2/4] Author MSI for Preview releases --- contrib/win32/install/client.wxs | 29 +++++++++++ contrib/win32/install/openssh.wixproj | 37 ++++++++++++++ contrib/win32/install/product.wxs | 39 +++++++++++++++ contrib/win32/install/server.wxs | 70 +++++++++++++++++++++++++++ contrib/win32/install/shared.wxs | 66 +++++++++++++++++++++++++ 5 files changed, 241 insertions(+) create mode 100644 contrib/win32/install/client.wxs create mode 100644 contrib/win32/install/openssh.wixproj create mode 100644 contrib/win32/install/product.wxs create mode 100644 contrib/win32/install/server.wxs create mode 100644 contrib/win32/install/shared.wxs diff --git a/contrib/win32/install/client.wxs b/contrib/win32/install/client.wxs new file mode 100644 index 00000000000..40043fb584b --- /dev/null +++ b/contrib/win32/install/client.wxs @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + ADD_PATH=1 + + + + + diff --git a/contrib/win32/install/openssh.wixproj b/contrib/win32/install/openssh.wixproj new file mode 100644 index 00000000000..6f4db057517 --- /dev/null +++ b/contrib/win32/install/openssh.wixproj @@ -0,0 +1,37 @@ + + + + Debug + x64 + 1.1.0 + openssh + package + bin\$(Platform)\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + false + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + + + + Debug + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/win32/install/product.wxs b/contrib/win32/install/product.wxs new file mode 100644 index 00000000000..6ce9514bfea --- /dev/null +++ b/contrib/win32/install/product.wxs @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + = 601]]> + + + + + + + + + + + + + + + diff --git a/contrib/win32/install/server.wxs b/contrib/win32/install/server.wxs new file mode 100644 index 00000000000..6731e13dade --- /dev/null +++ b/contrib/win32/install/server.wxs @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/win32/install/shared.wxs b/contrib/win32/install/shared.wxs new file mode 100644 index 00000000000..9642bae8d2e --- /dev/null +++ b/contrib/win32/install/shared.wxs @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5215fe79e32455efb3161dcd8b701ce1c30d8cef Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Mon, 26 Jul 2021 17:59:51 -0700 Subject: [PATCH 3/4] Resolve manual test issues --- contrib/win32/install/client.wxs | 2 +- contrib/win32/install/openssh.wixproj | 9 ++++++++- contrib/win32/install/product.wxs | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/contrib/win32/install/client.wxs b/contrib/win32/install/client.wxs index 40043fb584b..818447439b5 100644 --- a/contrib/win32/install/client.wxs +++ b/contrib/win32/install/client.wxs @@ -22,7 +22,7 @@ ADD_PATH=1 - + diff --git a/contrib/win32/install/openssh.wixproj b/contrib/win32/install/openssh.wixproj index 6f4db057517..cb701f7a046 100644 --- a/contrib/win32/install/openssh.wixproj +++ b/contrib/win32/install/openssh.wixproj @@ -8,12 +8,19 @@ package bin\$(Platform)\$(Configuration)\ obj\$(Platform)\$(Configuration)\ + + $(DefineConstants); + ProductVersion=$(ProductVersion); + false $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets - Debug + + $(DefineConstants); + Debug; + diff --git a/contrib/win32/install/product.wxs b/contrib/win32/install/product.wxs index 6ce9514bfea..502dc94e43e 100644 --- a/contrib/win32/install/product.wxs +++ b/contrib/win32/install/product.wxs @@ -1,7 +1,7 @@ - + @@ -31,7 +31,7 @@ - + From 65d6a12e6b1900640264fc26736150af27208e4b Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Mon, 26 Jul 2021 22:04:16 -0700 Subject: [PATCH 4/4] Resolve PR feedback --- contrib/win32/install/server.wxs | 2 +- contrib/win32/openssh/OpenSSHBuildHelper.psm1 | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/win32/install/server.wxs b/contrib/win32/install/server.wxs index 6731e13dade..c7a16c25ede 100644 --- a/contrib/win32/install/server.wxs +++ b/contrib/win32/install/server.wxs @@ -24,7 +24,7 @@ &1 >> $script:BuildLogFile @@ -654,7 +654,8 @@ function Get-VS2019BuildToolPath { return $null } - return $toolAvailable[0].FullName + + return $toolAvailable[0].FullName } function Get-VS2017BuildToolPath @@ -671,7 +672,8 @@ function Get-VS2017BuildToolPath { return $null } - return $toolAvailable[0].FullName + + return $toolAvailable[0].FullName } function Get-VS2015BuildToolPath @@ -687,7 +689,8 @@ function Get-VS2015BuildToolPath { return $null } - return $toolAvailable[0].FullName + + return $toolAvailable[0].FullName } function Get-Windows10SDKVersion