From 1709fe3c142003a05dec0ccfb0ca7aa54c2215bc Mon Sep 17 00:00:00 2001 From: Flor Elisa Chacon Ochoa Date: Thu, 13 Nov 2025 15:01:31 -0800 Subject: [PATCH] Split out WSLA MSI and update deploy scripts --- .github/copilot-instructions.md | 2 +- .pipelines/build-stage.yml | 3 + CMakeLists.txt | 1 + doc/docs/dev-loop.md | 2 +- msipackage/CMakeLists.txt | 6 +- msipackage/package.wix.in | 181 +------------------------ src/windows/wslaclient/DllMain.cpp | 2 +- tools/deploy/deploy-to-host.ps1 | 69 ++++++---- tools/deploy/deploy-to-vm.ps1 | 71 ++++++---- tools/test/test-setup.ps1 | 2 +- wslamsi/CMakeLists.txt | 49 +++++++ wslamsi/package.wix.in | 207 +++++++++++++++++++++++++++++ 12 files changed, 358 insertions(+), 237 deletions(-) create mode 100644 wslamsi/CMakeLists.txt create mode 100644 wslamsi/package.wix.in diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 4ff6e456c..e6921c0eb 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -37,7 +37,7 @@ Build parameters: - `cmake . -DBUILD_BUNDLE=TRUE` - Build bundle msix package (requires ARM64 built first) ### Deploying WSL (Windows Only) -- Install MSI: `bin\\\wsl.msi` +- Install MSI: `bin\\\wsl.msi` and `bin\\\wsla.msi` - OR use script: `powershell tools\deploy\deploy-to-host.ps1` - For Hyper-V VM: `powershell tools\deploy\deploy-to-vm.ps1 -VmName -Username -Password ` diff --git a/.pipelines/build-stage.yml b/.pipelines/build-stage.yml index 5d96214f6..eaa5fa714 100644 --- a/.pipelines/build-stage.yml +++ b/.pipelines/build-stage.yml @@ -34,6 +34,8 @@ parameters: pattern: "gluepackage.msix" - target: "msipackage" pattern: "wsl.msi" + - target: "wslamsi" + pattern: "wsla.msi" - name: platforms type: object @@ -267,6 +269,7 @@ stages: New-Item -ItemType Directory -Path "$(ob_outputDirectory)\bundle" -Force $arch = '${{ platform }}' Copy-Item -Path "bin\$arch\release\wsl.msi" -Destination "$(ob_outputDirectory)\bundle\wsl.$(version.WSL_PACKAGE_VERSION).$arch.msi" + Copy-Item -Path "bin\$arch\release\wsla.msi" -Destination "$(ob_outputDirectory)\bundle\wsla.$(version.WSLA_PACKAGE_VERSION).$arch.msi" - ${{ if eq(parameters.isRelease, 'true') }}: - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5 diff --git a/CMakeLists.txt b/CMakeLists.txt index 36de6a381..823a1421c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,7 @@ add_subdirectory(nuget) add_subdirectory(msixgluepackage) add_subdirectory(msipackage) add_subdirectory(msixinstaller) +add_subdirectory(wslamsi) add_subdirectory(src/windows/common) add_subdirectory(src/windows/service) add_subdirectory(src/windows/wslaservice) diff --git a/doc/docs/dev-loop.md b/doc/docs/dev-loop.md index e28a294aa..53ec0c8a4 100644 --- a/doc/docs/dev-loop.md +++ b/doc/docs/dev-loop.md @@ -40,7 +40,7 @@ Note: To build and deploy faster during development, see options in `UserConfig. ## Deploying WSL -Once the build is complete, you can install WSL by installing the MSI package found under `bin\\\wsl.msi`, or by running `powershell tools\deploy\deploy-to-host.ps1`. +Once the build is complete, you can install WSL by installing the MSI package found under `bin\\\` (`wsl.msi` and `wsla.msi`), or by running `powershell tools\deploy\deploy-to-host.ps1`. To deploy on a Hyper-V virtual machine, you can use `powershell tools\deploy\deploy-to-vm.ps1 -VmName -Username -Password ` diff --git a/msipackage/CMakeLists.txt b/msipackage/CMakeLists.txt index 6a0b065dd..cb1494e03 100644 --- a/msipackage/CMakeLists.txt +++ b/msipackage/CMakeLists.txt @@ -12,7 +12,7 @@ set(OUTPUT_PACKAGE ${BIN}/wsl.msi) set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/package.wix.in) set(PACKAGE_WIX ${BIN}/package.wix) set(CAB_CACHE ${BIN}/cab) -set(WINDOWS_BINARIES wsl.exe;wslg.exe;wslhost.exe;wslrelay.exe;wslservice.exe;wslserviceproxystub.dll;wslinstall.dll;wslaservice.exe;wsladiag.exe) +set(WINDOWS_BINARIES wsl.exe;wslg.exe;wslhost.exe;wslrelay.exe;wslservice.exe;wslserviceproxystub.dll;wslinstall.dll) if (WSL_BUILD_WSL_SETTINGS) list(APPEND WINDOWS_BINARIES "wslsettings/wslsettings.dll;wslsettings/wslsettings.exe;libwsl.dll") endif() @@ -52,7 +52,7 @@ add_custom_command( add_custom_target(msipackage DEPENDS ${OUTPUT_PACKAGE}) set_target_properties(msipackage PROPERTIES EXCLUDE_FROM_ALL FALSE SOURCES ${PACKAGE_WIX_IN}) -add_dependencies(msipackage wsl wslg wslservice wslhost wslrelay wslserviceproxystub init initramfs wslinstall msixgluepackage wslaservice wslaserviceproxystub wsladiag) +add_dependencies(msipackage wsl wslg wslservice wslhost wslrelay wslserviceproxystub init initramfs wslinstall msixgluepackage) if (WSL_BUILD_WSL_SETTINGS) add_dependencies(msipackage wslsettings libwsl) @@ -66,5 +66,5 @@ if (DEFINED WSL_POST_BUILD_COMMAND) POST_BUILD WORKING_DIRECTORY ${CMAKE_BINARY_DIR} USES_TERMINAL - COMMAND ${WSL_POST_BUILD_COMMAND} -Platform ${TARGET_PLATFORM} -BuildType ${CMAKE_BUILD_TYPE}) + COMMAND ${WSL_POST_BUILD_COMMAND} -Package wsl -Platform ${TARGET_PLATFORM} -BuildType ${CMAKE_BUILD_TYPE}) endif() \ No newline at end of file diff --git a/msipackage/package.wix.in b/msipackage/package.wix.in index e19bdbb20..35c0166a6 100644 --- a/msipackage/package.wix.in +++ b/msipackage/package.wix.in @@ -27,7 +27,6 @@ - @@ -41,12 +40,6 @@ - - - - - - @@ -235,176 +228,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -544,7 +372,6 @@ - @@ -672,9 +499,9 @@ Covers cases where: - The MSI package is installed for the first time and the old MSIX needs to be removed - The MSI package is uninstalled and the glue MSIX must be removed - + Must also run before CreateShortcuts since there might be an old MSIX shortcut that conflicts with ours. - Also, this action must not run during upgrades + Also, this action must not run during upgrades since upgrades start by first uninstalling the package, this isn't run if UPGRADINGPRODUCTCODE is set in the 'removing' MSI process. In this path, only the installing MSI process should run this action. @@ -725,7 +552,7 @@ - diff --git a/src/windows/wslaclient/DllMain.cpp b/src/windows/wslaclient/DllMain.cpp index 652f64516..f6fb369c2 100644 --- a/src/windows/wslaclient/DllMain.cpp +++ b/src/windows/wslaclient/DllMain.cpp @@ -100,7 +100,7 @@ try } }; - const auto downloadPath = wsl::windows::common::wslutil::DownloadFileImpl(PackageUrl, L"wsl.msi", callback); + const auto downloadPath = wsl::windows::common::wslutil::DownloadFileImpl(PackageUrl, L"wsla.msi", callback); auto cleanup = wil::scope_exit_log(WI_DIAGNOSTICS_INFO, [&]() { std::filesystem::remove(downloadPath); }); diff --git a/tools/deploy/deploy-to-host.ps1 b/tools/deploy/deploy-to-host.ps1 index 9d06af46e..e23a2ad36 100644 --- a/tools/deploy/deploy-to-host.ps1 +++ b/tools/deploy/deploy-to-host.ps1 @@ -2,6 +2,8 @@ [cmdletbinding(PositionalBinding = $false)] param ( + [ValidateSet("wsl", "wsla")] + [string[]]$Target = ("wsl", "wsla"), [ValidateSet("X64", "arm64")][string]$Platform = "X64", [ValidateSet("Debug", "Release")][string]$BuildType = "Debug", [string]$BuildOutputPath = [string](Get-Location), @@ -12,34 +14,47 @@ param ( $ErrorActionPreference = "Stop" -$PackagePath = "$BuildOutputPath\bin\$Platform\$BuildType\wsl.msi" - -# msiexec.exe doesn't like symlinks, so use the canonical path -$Target = (Get-ChildItem $PackagePath)[0].Target -if ($Target) +function Install-MSI { - $PackagePath = $Target + param ( + [Parameter(Mandatory)] + [ValidateSet("wsl", "wsla")] + [string]$Package + ) + + $PackagePath = "$BuildOutputPath\bin\$Platform\$BuildType\$Package.msi" + + # msiexec.exe doesn't like symlinks, so use the canonical path + $Target = (Get-ChildItem $PackagePath)[0].Target + if ($Target) + { + $PackagePath = $Target + } + + Write-Host -ForegroundColor Green "Installing: $PackagePath " + + $MSIArguments = @( + "/i" + $PackagePath + "/qn" + "/norestart" + ) + + if ($MsiArgs) + { + $MSIArguments += $MsiArgs + } + + $exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode + if ($exitCode -Ne 0) + { + Write-Host "Failed to install package: $exitCode" + exit 1 + } + + Write-Host -ForegroundColor Green "Package $PackagePath installed successfully" } -Write-Host -ForegroundColor Green "Installing: $PackagePath " - -$MSIArguments = @( - "/i" - $PackagePath - "/qn" - "/norestart" -) - -if ($MsiArgs) -{ - $MSIArguments += $MsiArgs +foreach ($t in $Target) { + Install-MSI -Package $t } - -$exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode -if ($exitCode -Ne 0) -{ - Write-Host "Failed to install package: $exitCode" - exit 1 -} - -Write-Host -ForegroundColor Green "Package $PackagePath installed successfully" diff --git a/tools/deploy/deploy-to-vm.ps1 b/tools/deploy/deploy-to-vm.ps1 index 667080a06..e1ea9a646 100644 --- a/tools/deploy/deploy-to-vm.ps1 +++ b/tools/deploy/deploy-to-vm.ps1 @@ -3,6 +3,7 @@ param ( [string]$VmName, [string]$Username, [string]$Password, + [ValidateSet("wsl", "wsla")][string[]]$Target = ("wsl", "wsla"), [ValidateSet("X64", "arm64")][string]$Platform = "X64", [ValidateSet("Debug", "Release")][string]$BuildType = "Debug", [string]$RemoteTempFolder = "C:\\", @@ -13,6 +14,44 @@ param ( $ErrorActionPreference = "Stop" +function Install-MSI +{ + param ( + [Parameter(Mandatory)] + [PSSession]$Session, + [Parameter(Mandatory)] + [ValidateSet("wsl", "wsla")] + [string]$PackageName + ) + + $Package = $BuildOutputPath + "/bin/$Platform/$BuildType/$PackageName.msi" + Copy-Item -ToSession $Session -Path $Package -Destination "$RemoteTempFolder" -Force + + Invoke-Command -Session $Session -ScriptBlock { + + $MSIArguments = @( + "/i" + "$using:RemoteTempFolder\$PackageName.msi" + "/qn" + "/norestart" + ) + + if ($using:ExtraMsiArgs) + { + $MSIArguments += $using:ExtraMsiArgs + } + + $exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode + if ($exitCode -Ne 0) + { + Write-Host "Failed to install package: $exitCode" + exit 1 + } + + Write-Host "Package $using:Package successfully deployed on $using:VmName" + } +} + if ([string]::IsNullOrEmpty($Password)) { $SecurePassword = New-Object System.Security.SecureString } @@ -23,32 +62,12 @@ else { $Credential = New-Object System.Management.Automation.PSCredential("$Username", $SecurePassword) $Session = New-PSSession -VMName $VmName -Credential $Credential -$Package = $BuildOutputPath + "/bin/$Platform/$BuildType/wsl.msi" -Copy-Item -ToSession $Session -Path $Package -Destination "$RemoteTempFolder" -Force - - -Invoke-Command -Session $Session -ScriptBlock { - - $MSIArguments = @( - "/i" - "$using:RemoteTempFolder\wsl.msi" - "/qn" - "/norestart" - ) - - if ($using:ExtraMsiArgs) +try { + foreach ($t in $Target) { - $MSIArguments += $using:ExtraMsiArgs + Install-MSI -Session $Session -Package $t } - - $exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode - if ($exitCode -Ne 0) - { - Write-Host "Failed to install package: $exitCode" - exit 1 - } - - Write-Host "Package $using:Package successfully deployed on $using:VmName" } - -Remove-PSSession -Session $Session \ No newline at end of file +finally { + Remove-PSSession -Session $Session +} \ No newline at end of file diff --git a/tools/test/test-setup.ps1 b/tools/test/test-setup.ps1 index 939ab508d..1087d4202 100644 --- a/tools/test/test-setup.ps1 +++ b/tools/test/test-setup.ps1 @@ -59,7 +59,7 @@ if ($Package) { ) $exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode - if ($exitCode -Ne 0) + if ($exitCode -NotIn (0, 1605)) { Write-Host "Failed to remove package: $exitCode" exit 1 diff --git a/wslamsi/CMakeLists.txt b/wslamsi/CMakeLists.txt new file mode 100644 index 000000000..62c1057a8 --- /dev/null +++ b/wslamsi/CMakeLists.txt @@ -0,0 +1,49 @@ +set(BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}) +set(OUTPUT_PACKAGE ${BIN}/wsla.msi) +set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/package.wix.in) +set(PACKAGE_WIX ${BIN}/package.wix) +set(CAB_CACHE ${BIN}/cab) +set(BINARIES wslaservice.exe;wslaserviceproxystub.dll;wsladiag.exe) + +set(BINARIES_DEPENDENCIES) +foreach(binary ${BINARIES}) + list(APPEND BINARIES_DEPENDENCIES "${BIN}/${binary}") +endforeach() + +if (${WSL_BUILD_THIN_PACKAGE}) + set(COMPRESS_PACKAGE "no") +else() + set(COMPRESS_PACKAGE "yes") +endif() + +configure_file(${PACKAGE_WIX_IN} ${PACKAGE_WIX}) +file(MAKE_DIRECTORY ${CAB_CACHE}) + +if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(COMPRESSION "high") +else() + set(COMPRESSION "none") +endif() + +add_custom_command( + OUTPUT ${OUTPUT_PACKAGE} + COMMAND ${WIX_SOURCE_DIR}/wix.exe build ${PACKAGE_WIX} -o ${OUTPUT_PACKAGE} -arch ${TARGET_PLATFORM} -dcl ${COMPRESSION} -cc ${CAB_CACHE} -pdbtype none + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/CmakeFiles/wslamsi" + VERBATIM + DEPENDS ${PACKAGE_WIX} ${BINARIES_DEPENDENCIES} # Make sure the package is rebuilt if any of the binaries or resources change +) + +add_custom_target(wslamsi DEPENDS ${OUTPUT_PACKAGE}) +set_target_properties(wslamsi PROPERTIES EXCLUDE_FROM_ALL FALSE SOURCES ${PACKAGE_WIX_IN}) +add_dependencies(wslamsi wslaservice wslaserviceproxystub wsladiag) + +set_source_files_properties(${OUTPUT_PACKAGE} PROPERTIES GENERATED TRUE) + +if (DEFINED WSL_POST_BUILD_COMMAND) + add_custom_command( + TARGET wslamsi + POST_BUILD + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + USES_TERMINAL + COMMAND ${WSL_POST_BUILD_COMMAND} -Package wsla -Platform ${TARGET_PLATFORM} -BuildType ${CMAKE_BUILD_TYPE}) +endif() \ No newline at end of file diff --git a/wslamsi/package.wix.in b/wslamsi/package.wix.in new file mode 100644 index 000000000..68a92a90d --- /dev/null +++ b/wslamsi/package.wix.in @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +