Skip to content

Commit

Permalink
Add x86 support to the MSI installer
Browse files Browse the repository at this point in the history
  • Loading branch information
mirichmo authored and daxian-dbw committed Nov 19, 2016
1 parent e23b0b2 commit c9fb03e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
6 changes: 4 additions & 2 deletions assets/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
<?define ProductGuid = "$(env.ProductGuid)" ?>
<?define ProductVersion = "$(env.ProductVersion)" ?>
<?define ProductVersionWithName = "$(var.ProductName)_$(var.ProductVersion)"?>
<?define ProductTargetArchitecture = "$(env.ProductTargetArchitecture)"?>
<?define ProductProgFilesDir = "$(env.ProductProgFilesDir)" ?>

<!-- Generate Your Own GUID for both ID and UpgradeCode attributes. -->
<!-- Note: UpgradeCode GUID MUST REMAIN SAME THROUGHOUT ALL VERSIONS -->
<!-- Otherwise, updates won't occur -->
<Product Id="$(var.ProductGuid)" Name="$(var.ProductVersionWithName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="{f7ba3e58-0be8-443b-ac91-f99dd1e7bd3b}">
<!-- Properties About The Package -->
<Package Id="*" Keywords="Installer" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />
<Package Id="*" Keywords="Installer" Platform="$(var.ProductTargetArchitecture)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />

<!-- Add PowerShell icon for executable -->
<Icon Id="PowerShellExe.ico" SourceFile="assets\Powershell_256.ico" />
Expand Down Expand Up @@ -51,7 +53,7 @@
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="$(var.ProductProgFilesDir)">
<Directory Id="INSTALLFOLDER" Name="PowerShell">
<Directory Id="$(var.ProductVersionWithName)" Name="$(var.ProductVersion)">
<Component Id="ProductVersionFolder" Guid="{e1a7f05e-0cd6-4227-80a8-e4fb311f045c}">
Expand Down
65 changes: 47 additions & 18 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ function Start-PSBuild {
[Parameter(ParameterSetName='FullCLR')]
[switch]$XamlGen,

[ValidateSet('x86', 'x64')] # TODO: At some point, we need to add ARM support to match CoreCLR
[string]$NativeHostArch = "x64",

[ValidateSet('Linux', 'Debug', 'Release', 'CodeCoverage', '')] # We might need "Checked" as well
[string]$Configuration,

Expand Down Expand Up @@ -169,13 +166,6 @@ function Start-PSBuild {
$msbuildConfiguration = 'Release'
}

# setup cmakeGenerator
if ($NativeHostArch -eq 'x86') {
$cmakeGenerator = 'Visual Studio 14 2015'
} else {
$cmakeGenerator = 'Visual Studio 14 2015 Win64'
}

} elseif ($IsLinux -or $IsOSX) {
foreach ($Dependency in 'cmake', 'make', 'g++') {
$precheck = $precheck -and (precheck $Dependency "Build dependency '$Dependency' not found. Run Start-PSBootstrap.")
Expand All @@ -200,6 +190,12 @@ function Start-PSBuild {
}
$script:Options = New-PSOptions @OptionsArguments

if (($script:Options.Runtime -match "-x86") -AND
($CrossGen))
{
throw "CrossGen is not currently supported for x86 releases."
}

if ($StopDevPowerShell) {
Stop-DevPowerShell
}
Expand Down Expand Up @@ -291,6 +287,19 @@ function Start-PSBuild {
try {
Push-Location "$PSScriptRoot\src\powershell-native"

$NativeHostArch = "x64"
if ($script:Options.Runtime -match "-x86")
{
$NativeHostArch = "x86"
}

# setup cmakeGenerator
if ($NativeHostArch -eq 'x86') {
$cmakeGenerator = 'Visual Studio 14 2015'
} else {
$cmakeGenerator = 'Visual Studio 14 2015 Win64'
}

# Compile native resources
$currentLocation = Get-Location
@("nativemsh/pwrshplugin") | % {
Expand Down Expand Up @@ -1105,11 +1114,11 @@ function Start-PSPackage {
Write-Verbose "Packaging RID: '$Runtime'; Packaging Configuration: '$Configuration'" -Verbose

# Make sure the most recent build satisfies the package requirement
if (-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
-not $Script:Options.CrossGen -or ## Last build didn't specify -CrossGen
$Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
$Script:Options.Framework -ne "netcoreapp1.0") ## Last build wasn't for CoreCLR
if (-not $Script:Options -or ## Start-PSBuild hasn't been executed yet
((-not $Script:Options.CrossGen) -AND -not ($Runtime -match "-x86")) -or ## Last build didn't specify -CrossGen OR CrossGen check skipped since it is not supported for x86
$Script:Options.Runtime -ne $Runtime -or ## Last build wasn't for the required RID
$Script:Options.Configuration -ne $Configuration -or ## Last build was with configuration other than 'Release'
$Script:Options.Framework -ne "netcoreapp1.0") ## Last build wasn't for CoreCLR
{
# It's possible that the most recent build doesn't satisfy the package requirement but
# an earlier build does. e.g., run the following in order on win10-x64:
Expand Down Expand Up @@ -1169,14 +1178,21 @@ function Start-PSPackage {
Write-Output $zipPackagePath
}
"msi" {
$TargetArchitecture = "x64"
if ($Runtime -match "-x86")
{
$TargetArchitecture = "x86"
}

$Arguments = @{
ProductNameSuffix = $NameSuffix
ProductNameSuffix = $NameSuffix;
ProductSourcePath = $Source;
ProductVersion = $Version;
AssetsPath = "$PSScriptRoot\assets";
LicenseFilePath = "$PSScriptRoot\assets\license.rtf";
# Product Guid needs to be unique for every PowerShell version to allow SxS install
ProductGuid = [Guid]::NewGuid()
ProductGuid = [Guid]::NewGuid();
ProductTargetArchitecture = $TargetArchitecture;
}
New-MSIPackage @Arguments
}
Expand Down Expand Up @@ -2170,7 +2186,13 @@ function New-MSIPackage
# Path to license.rtf file - for the EULA
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $LicenseFilePath
[string] $LicenseFilePath,

# Architecture to use when creating the MSI
[Parameter(Mandatory = $true)]
[ValidateSet("x86", "x64")]
[ValidateNotNullOrEmpty()]
[string] $ProductTargetArchitecture

)

Expand Down Expand Up @@ -2203,6 +2225,13 @@ function New-MSIPackage
[Environment]::SetEnvironmentVariable("ProductGuid", $ProductGuid, "Process")
[Environment]::SetEnvironmentVariable("ProductVersion", $ProductVersion, "Process")
[Environment]::SetEnvironmentVariable("ProductVersionWithName", $productVersionWithName, "Process")
[Environment]::SetEnvironmentVariable("ProductTargetArchitecture", $ProductTargetArchitecture, "Process")
$ProductProgFilesDir = "ProgramFiles64Folder"
if ($ProductTargetArchitecture -eq "x86")
{
$ProductProgFilesDir = "ProgramFilesFolder"
}
[Environment]::SetEnvironmentVariable("ProductProgFilesDir", $ProductProgFilesDir, "Process")

$wixFragmentPath = (Join-path $env:Temp "Fragment.wxs")
$wixObjProductPath = (Join-path $env:Temp "Product.wixobj")
Expand Down

0 comments on commit c9fb03e

Please sign in to comment.