From d476258f99cecda98d468cd601117f77385170fc Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Mon, 6 Dec 2021 12:33:24 -0800 Subject: [PATCH] Initial MSI authoring for Previews (#521) --- contrib/win32/install/client.wxs | 29 +++++++ contrib/win32/install/openssh.wixproj | 44 ++++++++++ contrib/win32/install/product.wxs | 39 +++++++++ contrib/win32/install/server.wxs | 70 ++++++++++++++++ contrib/win32/install/shared.wxs | 66 +++++++++++++++ contrib/win32/openssh/OpenSSHBuildHelper.psm1 | 82 +++++++++++++++---- 6 files changed, 312 insertions(+), 18 deletions(-) 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 000000000..818447439 --- /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 000000000..cb701f7a0 --- /dev/null +++ b/contrib/win32/install/openssh.wixproj @@ -0,0 +1,44 @@ + + + + Debug + x64 + 1.1.0 + openssh + package + bin\$(Platform)\$(Configuration)\ + obj\$(Platform)\$(Configuration)\ + + $(DefineConstants); + ProductVersion=$(ProductVersion); + + false + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + + + + + $(DefineConstants); + Debug; + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/win32/install/product.wxs b/contrib/win32/install/product.wxs new file mode 100644 index 000000000..502dc94e4 --- /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 000000000..c7a16c25e --- /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 000000000..9642bae8d --- /dev/null +++ b/contrib/win32/install/shared.wxs @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/win32/openssh/OpenSSHBuildHelper.psm1 b/contrib/win32/openssh/OpenSSHBuildHelper.psm1 index 524405449..9c1a2bbef 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 -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,27 @@ 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") { @@ -628,7 +672,8 @@ function Get-VS2017BuildToolPath { return $null } - return $toolAvailable[0].FullName + + return $toolAvailable[0].FullName } function Get-VS2015BuildToolPath @@ -644,7 +689,8 @@ function Get-VS2015BuildToolPath { return $null } - return $toolAvailable[0].FullName + + return $toolAvailable[0].FullName } function Get-Windows10SDKVersion