From b79d263e1dde308552539401ab0e227e8e66ad74 Mon Sep 17 00:00:00 2001
From: Romain <96626929+Romanitho@users.noreply.github.com>
Date: Thu, 22 Aug 2024 23:25:59 +0200
Subject: [PATCH] Migrate and convert from WiX V3 to Wix V5
---
.../workflows/WAU-AutoCreatePreVersion.yml | 23 +-
.github/workflows/WAU-CreateNewVersion.yml | 26 +-
Sources/Wix/Make_MSI.ps1 | 480 ------------------
Sources/Wix/build.wxs | 367 +++++++++++++
4 files changed, 392 insertions(+), 504 deletions(-)
delete mode 100644 Sources/Wix/Make_MSI.ps1
create mode 100644 Sources/Wix/build.wxs
diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml
index da2e7ef..90f0ae2 100644
--- a/.github/workflows/WAU-AutoCreatePreVersion.yml
+++ b/.github/workflows/WAU-AutoCreatePreVersion.yml
@@ -72,25 +72,24 @@ jobs:
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi
Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait
- echo "### Duplicate WAU to WAU_x86 and WAU_x64"
- Copy-Item -Path ".\Sources\Winget-AutoUpdate" -Destination ".\Sources\Winget-AutoUpdate_x64" -Recurse -Force
- #Copy-Item -Path ".\Sources\Winget-AutoUpdate" -Destination ".\Sources\Winget-AutoUpdate_x86" -Recurse -Force
+ echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###"
+ Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force
- echo "### Copy ServiceUI.exe (x64/x86) to 'Sources/WAU_(x86/x64)/Winget-AutoUpdate' folders ###"
- Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate_x64\ServiceUI.exe" -Force
- #Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x86\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate_x86\ServiceUI.exe" -Force
+ echo "Install WiX"
+ dotnet new console
+ dotnet tool install --global wix --version 5.0.1
+ wix extension add WixToolset.UI.wixext/5.0.1 -g
+ wix extension add WixToolset.Util.wixext/5.0.1 -g
echo "### Create WAU msi ###"
- .\Sources\Wix\Make_MSI.ps1 -Sources ".\Sources\Winget-AutoUpdate_x64" -OutputFolder ".\" -ProductVersion ${{ steps.versioning.outputs.version }} -NoX86
- #.\Sources\Wix\Make_MSI.ps1 -Sources ".\Sources\Winget-AutoUpdate_x86" -OutputFolder ".\" -ProductVersion ${{ steps.versioning.outputs.version }} -NoX64
+ cd .\Sources\Wix\
+ wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ steps.versioning.outputs.version }} -d Comment=NIGHTLY -d PreRelease=1
+ cd ..\..
echo "### Get MSI file SHA ###"
$MsiSHA = (Get-FileHash .\WAU.msi).hash
echo " - WAU.msi SHA256: $MsiSHA"
echo "MSI_SHA=$MsiSHA" >> $env:GITHUB_ENV
- #$MsiX86HA = (Get-FileHash .\WAU_x86.msi).hash
- #echo " - WAU_x86.msi SHA256: $MsiX86HA"
- #echo "MSI_SHA_X86=$MsiX86HA" >> $env:GITHUB_ENV
echo "### Zip ADMX ###"
Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force
@@ -115,7 +114,7 @@ jobs:
body: |
|Files|Hash (SHA256)|
|---|---|
- |[WAU.msi](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU.msi) (x64 only)|${{ env.MSI_SHA }}|
+ |[WAU.msi](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU.msi) (x64)|${{ env.MSI_SHA }}|
|[WAU_ADMX.zip](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU_ADMX.zip)|${{ env.ADMX_SHA }}|
- name: URL to release
diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml
index 008255c..11dd6bc 100644
--- a/.github/workflows/WAU-CreateNewVersion.yml
+++ b/.github/workflows/WAU-CreateNewVersion.yml
@@ -43,6 +43,9 @@ jobs:
run: |
echo "Next Release version: ${{ steps.versioning.outputs.version }}"
+ - name: Setup MSBuild
+ uses: microsoft/setup-msbuild@v2
+
- name: Build project
shell: powershell
run: |
@@ -50,25 +53,24 @@ jobs:
wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi
Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait
- echo "### Duplicate WAU to WAU_x86 and WAU_x64"
- Copy-Item -Path ".\Sources\Winget-AutoUpdate" -Destination ".\Sources\Winget-AutoUpdate_x64" -Recurse -Force
- #Copy-Item -Path ".\Sources\Winget-AutoUpdate" -Destination ".\Sources\Winget-AutoUpdate_x86" -Recurse -Force
+ echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###"
+ Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force
- echo "### Copy ServiceUI.exe (x64/x86) to 'Sources/WAU_(x86/x64)/Winget-AutoUpdate' folders ###"
- Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate_x64\ServiceUI.exe" -Force
- #Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x86\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate_x86\ServiceUI.exe" -Force
+ echo "Install WiX"
+ dotnet new console
+ dotnet tool install --global wix --version 5.0.1
+ wix extension add WixToolset.UI.wixext/5.0.1 -g
+ wix extension add WixToolset.Util.wixext/5.0.1 -g
echo "### Create WAU msi ###"
- .\Sources\Wix\Make_MSI.ps1 -Sources ".\Sources\Winget-AutoUpdate_x64" -OutputFolder ".\" -ProductVersion ${{ steps.versioning.outputs.version }} -NoX86
- #.\Sources\Wix\Make_MSI.ps1 -Sources ".\Sources\Winget-AutoUpdate_x86" -OutputFolder ".\" -ProductVersion ${{ steps.versioning.outputs.version }} -NoX64
+ cd .\Sources\Wix\
+ wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ steps.versioning.outputs.version }} -d Comment=STABLE -d PreRelease=0
+ cd ..\..
echo "### Get MSI file SHA ###"
$MsiSHA = (Get-FileHash .\WAU.msi).hash
echo " - WAU.msi SHA256: $MsiSHA"
echo "MSI_SHA=$MsiSHA" >> $env:GITHUB_ENV
- #$MsiX86HA = (Get-FileHash .\WAU_x86.msi).hash
- #echo " - WAU_x86.msi SHA256: $MsiX86HA"
- #echo "MSI_SHA_X86=$MsiX86HA" >> $env:GITHUB_ENV
echo "### Zip ADMX ###"
Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force
@@ -93,7 +95,7 @@ jobs:
body: |
|Files|Hash (SHA256)|
|---|---|
- |[WAU.msi](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU.msi) (x64 only)|${{ env.MSI_SHA }}|
+ |[WAU.msi](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU.msi) (x64)|${{ env.MSI_SHA }}|
|[WAU_ADMX.zip](https://github.com/Romanitho/WAU-MSI/releases/download/v${{ steps.versioning.outputs.version }}/WAU_ADMX.zip)|${{ env.ADMX_SHA }}|
diff --git a/Sources/Wix/Make_MSI.ps1 b/Sources/Wix/Make_MSI.ps1
deleted file mode 100644
index b274742..0000000
--- a/Sources/Wix/Make_MSI.ps1
+++ /dev/null
@@ -1,480 +0,0 @@
-[Cmdletbinding()]
-Param(
- [Parameter(Mandatory = $false, Position = 0)] [string] $Path = (Get-Location).Path,
- [Parameter(Mandatory = $false)] [string] $Sources = "$($Path)\Sources\Winget-AutoUpdate\",
- [Parameter(Mandatory = $false)] [string] $OutputFolder = $Path,
- [Parameter(Mandatory = $false)] [string] $IconFile = "$($Path)\Sources\Wix\files\icon.ico",
- [Parameter(Mandatory = $false)] [string] $BannerFile = "$($Path)\Sources\Wix\files\banner.bmp",
- [Parameter(Mandatory = $false)] [string] $DialogFile = "$($Path)\Sources\Wix\files\dialog.bmp",
- [Parameter(Mandatory = $false)] [string] $ProductId = "WAU",
- [Parameter(Mandatory = $false)] [string] $ProductName = "Winget-AutoUpdate",
- [Parameter(Mandatory = $false)] [string] $ProductVersion = "1.0.0",
- [Parameter(Mandatory = $false)] [string] $Manufacturer = "Romanitho",
- [Parameter(Mandatory = $false)] [string] $HelpLink = "https://github.com/Romanitho/Winget-AutoUpdate",
- [Parameter(Mandatory = $false)] [string] $AboutLink = "https://github.com/Romanitho/Winget-AutoUpdate",
- [Parameter(Mandatory = $false)] [string] $UpgradeCodeX86 = "B96866C0-EB44-4C0A-9477-2E5BB09CB9EF",
- [Parameter(Mandatory = $false)] [string] $UpgradeCodeX64 = "BDDEA607-F4AF-4229-8610-16E3B6455FDC",
- [Parameter(Mandatory = $false)] [switch] $PreRelease,
- [Parameter(Mandatory = $false)] [switch] $NoX86,
- [Parameter(Mandatory = $false)] [switch] $NoX64
-)
-
-$ProgressPreference = "SilentlyContinue"
-
-# WiX paths
-If (!(Get-ChildItem -Path "$env:HOMEDRIVE\Program Files*\WiX*\" -Filter heat.exe -Recurse)) {
- $ToolSetURL = "https://github.com/wixtoolset/wix3/releases/download/wix314rtm/wix314.exe"
- Invoke-WebRequest -Uri $ToolSetURL -OutFile (Join-Path $Path "\wix.exe") -UseBasicParsing
- Start-Process (Join-Path $Path "\wix.exe") -ArgumentList "/S" -Wait
-}
-$wixDir = Split-Path ((((Get-ChildItem -Path "$env:HOMEDRIVE\Program Files*\WiX*\" -Filter heat.exe -Recurse) | Select-Object FullName)[0]).FullName)
-$heatExe = Join-Path $wixDir "heat.exe"
-$candleExe = Join-Path $wixDir "candle.exe"
-$lightExe = Join-Path $wixDir "light.exe"
-
-if ($PreRelease) {
- $Comment = "NIGHTLY"
- $UpdatePreRelease = "#1"
-}
-else {
- $Comment = "STABLE"
- $UpdatePreRelease = "#0"
-}
-
-# Platform settings
-$platforms = @()
-
-$x86Settings = @{
- 'arch' = 'x86';
- 'sysFolder' = 'System32';
- 'progfolder' = 'ProgramFilesFolder';
- 'upgradeCode' = $UpgradeCodeX86;
- 'productName' = "${ProductName} (x86)";
- 'win64' = 'no';
- 'outputMsi' = (Join-Path $OutputFolder ($productID + "_x86.msi"))
-}
-$x64Settings = @{
- 'arch' = 'x64';
- 'sysFolder' = 'Sysnative';
- 'progfolder' = 'ProgramFiles64Folder';
- 'upgradeCode' = $UpgradeCodeX64;
- 'productName' = "${ProductName}";
- 'win64' = 'yes';
- 'outputMsi' = (Join-Path $OutputFolder ($productID + ".msi"))
-}
-
-If (!$Nox86) {
- $platforms += $x86Settings
-}
-If (!$Nox64) {
- $platforms += $x64Settings
-}
-
-# Do the build
-foreach ($platform in $platforms) {
- $platformArch = $platform.arch
- $platformSysFolder = $platform.sysFolder
- $platformProgFolder = $platform.progFolder
- $platformUpgradeCode = $platform.upgradeCode
- $platformProductName = $platform.productName
- $platformWin64 = $platform.win64
-
- $modulesWxs = Join-Path $Path "_modules${platformArch}.wxs"
- $productWxs = Join-Path $Path ".wxs${platformArch}"
- $modulesWixobj = Join-Path $Path "_modules${platformArch}.wixobj"
- $productWixobj = Join-Path $Path ".wixobj${platformArch}"
-
-
- # Build XML
- $wixXml = [xml] @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DESKTOPSHORTCUT = 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
- "1"]]>
- WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed
- 1
- 1
- 1
- 1
- NOT WIXUI_DONTVALIDATEPATH
- "1"]]>
- WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"
- 1
- 1
- NOT Installed
- Installed
- 1
- 1
- 1
- 1
- NOT Installed
- Installed
- 1
-
-
-
-
-
-
-
-
-
- DESKTOPSHORTCUT_VALUE = "#1"
- "#1")]]>
-
-
-
-
- NOTIFICATIONLEVEL
- "#1")]]>
-
- USERCONTEXT_REG = "#1"
- "#1")]]>
-
- DISABLEWAUAUTOUPDATE_REG = "#1"
- UPDATESINTERVAL
- "#1")]]>
-
- UPDATESATLOGON_REG = "#1"
- BLACKLIST_PATH
- WHITELIST_PATH
- BLACKLIST_PATH OR USEWHITELIST = "#0"
- WHITELIST_PATH OR USEWHITELIST = "#1"
- LISTPATH
- MODSPATH
- AZUREBLOBURL
- DONOTRUNONMETERED
- UPDATESATTIME
- BYPASSLISTFORUSERS
- MAXLOGFILES
- MAXLOGSIZE
- "#1")]]>
-
-
-
-
-
-
-
-
-
- RUN_WAU="YES"
- NOT (REMOVE="ALL")
- REMOVE="ALL" OR REINSTALL
-
-
-
-"@
-
-
- # Save XML and create productWxs
- $wixXml.Save($modulesWxs)
- & $heatExe dir $Sources -nologo -sfrag -sw5150 -ag -srd -gg -dir $ProductName -out $productWxs -cg INSTALLDIR -dr INSTALLDIR
-
- # Produce wixobj files
- & $candleexe $modulesWxs -out $modulesWixobj
- & $candleexe $productWxs -out $productWixobj
-}
-foreach ($platform in $platforms) {
- $platformArch = $platform.arch
- $modulesWixobj = Join-Path $Path "_modules${platformArch}.wixobj"
- $productWixobj = Join-Path $Path ".wixobj${platformArch}"
- $platformOutputMsi = $platform.outputMsi
-
- # Produce the MSI file
- & $lightexe -sval -sw1076 -spdb -ext WixUIExtension -ext WixUtilExtension -out $platformOutputMsi $modulesWixobj $productWixobj -b $Sources -sice:ICE91 -sice:ICE69 -sice:ICE38 -sice:ICE57 -sice:ICE64 -sice:ICE204 -sice:ICE80
-}
diff --git a/Sources/Wix/build.wxs b/Sources/Wix/build.wxs
new file mode 100644
index 0000000..605cfb8
--- /dev/null
+++ b/Sources/Wix/build.wxs
@@ -0,0 +1,367 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+