diff --git a/.pipelines/templates/windows-package-build.yml b/.pipelines/templates/windows-package-build.yml index 9861c2a7314e..ea724a2e289d 100644 --- a/.pipelines/templates/windows-package-build.yml +++ b/.pipelines/templates/windows-package-build.yml @@ -78,19 +78,6 @@ jobs: ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue - pwsh: | - # cleanup previous install - if((Test-Path "${env:ProgramFiles(x86)}\WiX Toolset xcopy")) { - Remove-Item "${env:ProgramFiles(x86)}\WiX Toolset xcopy" -Recurse -Force - } - $toolsDir = New-Item -ItemType Directory -Path '$(Build.ArtifactStagingDirectory)\tools' - $wixUri = 'https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip' - - Invoke-RestMethod -Uri $wixUri -OutFile '$(Build.ArtifactStagingDirectory)\tools\wix.zip' -MaximumRetryCount 5 -RetryIntervalSec 10 - Import-Module '$(PowerShellRoot)\tools\releaseBuild\Images\microsoft_powershell_windowsservercore\wix.psm1' - $isArm64 = '$(Runtime)' -eq 'arm64' - - Install-WixZip -zipPath '$(Build.ArtifactStagingDirectory)\tools\wix.zip' -arm64:$isArm64 - $msixUrl = '$(makeappUrl)' Invoke-RestMethod -Uri $msixUrl -OutFile '$(Pipeline.Workspace)\makeappx.zip' Expand-Archive '$(Pipeline.Workspace)\makeappx.zip' -destination '\' -Force diff --git a/build.psm1 b/build.psm1 index 9d1b2e7c5d9c..b3aade4883d9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -778,7 +778,7 @@ function Restore-PSPackage if (-not $ProjectDirs) { - $ProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen", "$PSScriptRoot/src/Modules") + $ProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen", "$PSScriptRoot/src/Modules", "$PSScriptRoot/tools/wix") if ($Options.Runtime -like 'fxdependent*') { $ProjectDirs += "$PSScriptRoot/src/Microsoft.PowerShell.GlobalTool.Shim" @@ -2295,6 +2295,11 @@ function Start-PSBootstrap { $psInstallFile = [System.IO.Path]::Combine($PSScriptRoot, "tools", "install-powershell.ps1") & $psInstallFile -AddToPath } + if ($Package) { + Import-Module '$(PowerShellRoot)\tools\wix\wix.psm1' + $isArm64 = '$(Runtime)' -eq 'arm64' + Install-Wix -arm64:$isArm64 + } } } finally { Pop-Location diff --git a/tools/wix/Microsoft.PowerShell.Packaging.csproj b/tools/wix/Microsoft.PowerShell.Packaging.csproj new file mode 100644 index 000000000000..bddbe6474de0 --- /dev/null +++ b/tools/wix/Microsoft.PowerShell.Packaging.csproj @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1 b/tools/wix/wix.psm1 similarity index 70% rename from tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1 rename to tools/wix/wix.psm1 index e5e1610bc2f4..a6fcf922d3c4 100644 --- a/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1 +++ b/tools/wix/wix.psm1 @@ -4,14 +4,19 @@ Import-Module "$PSScriptRoot\dockerInstall.psm1" # Install using Wix Zip because the MSI requires an older version of dotnet # which was large and unstable in docker -function Install-WixZip +function Install-Wix { - param($zipPath, $arm64 = $false) + param($arm64 = $false) $targetRoot = $arm64 ? "${env:ProgramFiles(x86)}\Arm Support WiX Toolset xcopy" : "${env:ProgramFiles(x86)}\WiX Toolset xcopy" + # cleanup previous install + if(Test-Path $targetRoot) { + Remove-Item $targetRoot -Recurse -Force + } $binPath = Join-Path -Path $targetRoot -ChildPath 'bin' - Write-Verbose "Expanding $zipPath to $binPath ..." -Verbose - Expand-Archive -Path $zipPath -DestinationPath $binPath -Force + Register-PSRepository -Name NuGetGallery -SourceLocation https://api.nuget.org/v3/index.json + # keep version in sync with Microsoft.PowerShell.Packaging.csproj + Save-Module -name wix -RequiredVersion 3.14.1 -path "$binPath/" $docExpandPath = Join-Path -Path $binPath -ChildPath 'doc' $sdkExpandPath = Join-Path -Path $binPath -ChildPath 'sdk' $docTargetPath = Join-Path -Path $targetRoot -ChildPath 'doc'