diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 11f406dc5..7468f50ab 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 132245630..e480de62d 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.WSL_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 c0a350ad3..951ccccd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,7 +220,7 @@ if (${WSL_BUILD_THIN_PACKAGE}) endif () string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) # make sure /Zi is removed from the debug flags -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /W3 /WX /ZH:SHA_256") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /W3 /WX /ZH:SHA_256 /Zm1000") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7 -DDEBUG -DDBG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /guard:cf /Qspectre") @@ -414,6 +414,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/cloudtest/TestGroup.xml.in b/cloudtest/TestGroup.xml.in index 1554e9cda..b80a6a8ef 100644 --- a/cloudtest/TestGroup.xml.in +++ b/cloudtest/TestGroup.xml.in @@ -6,6 +6,7 @@ + @@ -22,6 +23,6 @@ - + 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..d955ce21a 100644 --- a/msipackage/CMakeLists.txt +++ b/msipackage/CMakeLists.txt @@ -9,10 +9,10 @@ else() endif() set(OUTPUT_PACKAGE ${BIN}/wsl.msi) -set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/package.wix.in) -set(PACKAGE_WIX ${BIN}/package.wix) +set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/msipackage.wix.in) +set(PACKAGE_WIX ${BIN}/msipackage.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} -Target wsl -Platform ${TARGET_PLATFORM} -BuildType ${CMAKE_BUILD_TYPE}) endif() \ No newline at end of file diff --git a/msipackage/package.wix.in b/msipackage/msipackage.wix.in similarity index 74% rename from msipackage/package.wix.in rename to msipackage/msipackage.wix.in index 0ef367e0d..3e72d9bde 100644 --- a/msipackage/package.wix.in +++ b/msipackage/msipackage.wix.in @@ -27,7 +27,6 @@ - @@ -41,12 +40,6 @@ - - - - - - @@ -226,176 +219,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -535,7 +363,6 @@ - @@ -663,9 +490,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. @@ -716,7 +543,7 @@ - @@ -727,4 +554,3 @@ - diff --git a/src/windows/service/exe/ServiceMain.cpp b/src/windows/service/exe/ServiceMain.cpp index 915fcd7c9..ec43fdc82 100644 --- a/src/windows/service/exe/ServiceMain.cpp +++ b/src/windows/service/exe/ServiceMain.cpp @@ -37,7 +37,7 @@ struct WslServiceSecurityPolicy { // COM Access and Launch permissions allowed for authenticated user, principal self, and system. // 0xB = (COM_RIGHTS_EXECUTE | COM_RIGHTS_EXECUTE_LOCAL | COM_RIGHTS_ACTIVATE_LOCAL) - // N.B. This should be kept in sync with the security descriptors in the appxmanifest and package.wix. + // N.B. This should be kept in sync with the security descriptors in the appxmanifest and msipackage.wix. return L"O:BAG:BAD:(A;;0xB;;;AU)(A;;0xB;;;PS)(A;;0xB;;;SY)"; } }; 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/src/windows/wslaservice/exe/ServiceMain.cpp b/src/windows/wslaservice/exe/ServiceMain.cpp index 872ed438a..707adf9e8 100644 --- a/src/windows/wslaservice/exe/ServiceMain.cpp +++ b/src/windows/wslaservice/exe/ServiceMain.cpp @@ -35,7 +35,7 @@ struct WslaServiceSecurityPolicy { // COM Access and Launch permissions allowed for authenticated user, principal self, and system. // 0xB = (COM_RIGHTS_EXECUTE | COM_RIGHTS_EXECUTE_LOCAL | COM_RIGHTS_ACTIVATE_LOCAL) - // N.B. This should be kept in sync with the security descriptors in the appxmanifest and package.wix. + // N.B. This should be kept in sync with the security descriptors in the appxmanifest and wslamsi.wix. return L"O:BAG:BAD:(A;;0xB;;;AU)(A;;0xB;;;PS)(A;;0xB;;;SY)"; } }; diff --git a/src/windows/wslinstall/DllMain.cpp b/src/windows/wslinstall/DllMain.cpp index e0cacc8c4..89a12f2d3 100644 --- a/src/windows/wslinstall/DllMain.cpp +++ b/src/windows/wslinstall/DllMain.cpp @@ -8,7 +8,7 @@ Module Name: Abstract: - This file contains various methods used during MSI installation (see package.wix.in) + This file contains various methods used during MSI installation (see msipackage.wix.in) --*/ diff --git a/test/windows/Common.cpp b/test/windows/Common.cpp index 301fe537a..471953df4 100644 --- a/test/windows/Common.cpp +++ b/test/windows/Common.cpp @@ -932,7 +932,7 @@ for pid in "${pids_to_dump[@]}" ; do echo "Failed to dump process $pid" fi - rm "core.$pid" + rm "core.$pid" fi done @@ -2082,8 +2082,8 @@ Return Value: -ExecutionPolicy Bypass \ -Command \"" + setupScript.value() + L" -Version '" + getTestParam(L"Version") + L"'" + L" -DistroPath " + g_testDistroPath + - L" -DistroName " + LXSS_DISTRO_NAME_TEST_L + L" -Package '" + getTestParam(L"Package") + L"'" + L" -UnitTestsPath " + - getOptionalTestParam(L"UnitTestsPath").value_or(L"$null"); + L" -DistroName " + LXSS_DISTRO_NAME_TEST_L + L" -Package '" + getTestParam(L"Package") + L"'" + L" -WslaPackage '" + + getTestParam(L"WslaPackage") + L"'" + L" -UnitTestsPath " + getOptionalTestParam(L"UnitTestsPath").value_or(L"$null"); if (getOptionalTestParam(L"AllowUnsigned") == L"1") { 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/run-tests.ps1 b/tools/test/run-tests.ps1 index 4f2a2178e..88d0734d2 100644 --- a/tools/test/run-tests.ps1 +++ b/tools/test/run-tests.ps1 @@ -32,6 +32,7 @@ param ( [string]$DistroPath = ".\test_distro.tar.gz", [string]$TestDataPath = ".\test_data", [string]$Package = ".\installer.msix", + [string]$WslaPackage = ".\wsla.msi", [string]$UnitTestsPath = ".\unit_tests", [switch]$PullRequest = $false, [string]$TestDllPath = ".\wsltests.dll", @@ -48,7 +49,7 @@ if ($Fast) $SetupScript = $null } -te.exe $TestDllPath /p:SetupScript=$SetupScript /p:Version=$Version /p:DistroPath=$DistroPath /p:TestDataPath=$TestDataPath /p:Package=$Package /p:UnitTestsPath=$UnitTestsPath /p:PullRequest=$PullRequest /p:AllowUnsigned=1 @TeArgs +te.exe $TestDllPath /p:SetupScript=$SetupScript /p:Version=$Version /p:DistroPath=$DistroPath /p:TestDataPath=$TestDataPath /p:Package=$Package /p:WslaPackage=$WslaPackage /p:UnitTestsPath=$UnitTestsPath /p:PullRequest=$PullRequest /p:AllowUnsigned=1 @TeArgs if (!$?) { diff --git a/tools/test/setup-vm-for-tests.ps1 b/tools/test/setup-vm-for-tests.ps1 index 2a6cb4b0b..0cad2869d 100644 --- a/tools/test/setup-vm-for-tests.ps1 +++ b/tools/test/setup-vm-for-tests.ps1 @@ -138,6 +138,7 @@ Invoke-Command -Session $Session -ArgumentList $RemoteFolder -ScriptBlock { New-Item -ItemType Directory -Path "$Using:RemoteFolder" -Force } Copy-Item -ToSession $Session -Path "$Bin/installer.msix" -Destination $RemoteFolder -Force +Copy-Item -ToSession $Session -Path "$Bin/wsla.msi" -Destination $RemoteFolder -Force Copy-Item -ToSession $Session -Path "$Bin/wsltests.dll" -Destination $RemoteFolder -Force Copy-Item -ToSession $Session -Path "$Bin/testplugin.dll" -Destination $RemoteFolder -Force Copy-Item -ToSession $Session -Path "$Bin/wslaclient.dll" -Destination $RemoteFolder -Force diff --git a/tools/test/test-setup.ps1 b/tools/test/test-setup.ps1 index 939ab508d..74a12f283 100644 --- a/tools/test/test-setup.ps1 +++ b/tools/test/test-setup.ps1 @@ -9,6 +9,8 @@ The name to be given to the imported distro. .PARAMETER Package Path to the wsl.msix package to install. Optional. +.PARAMETER WslaPackage + Path to the wsla.msi package to install. Optional. .PARAMETER UnitTestsPath Path to the linux/unit_tests directory to copy and install the unit tests. Optional. .PARAMETER PostInstallCommand @@ -23,6 +25,7 @@ Param ( $DistroPath, $DistroName, $Package = $null, + $WslaPackage = $null, $UnitTestsPath = $null, $PostInstallCommand = $null, [switch]$AllowUnsigned) @@ -40,14 +43,13 @@ function Run { } } -if ($Package) { - $installedPackage = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemforLinux -AllUsers - if ($installedPackage) { - Write-Host "Removing previous package installation" - Remove-AppxPackage $installedPackage -AllUsers - } +# Removes an installed MSI using a ProductCode extracted from the registry. +function RemoveMSI +{ + [CmdletBinding()] + param([string]$MSIDataRegistryPath) - $installedMsi = (Get-ItemProperty -Path "HKLM:Software\Microsoft\Windows\CurrentVersion\Lxss\MSI" -Name ProductCode -ErrorAction Ignore) + $installedMsi = (Get-ItemProperty -Path $MSIDataRegistryPath -Name ProductCode -ErrorAction Ignore) if ($installedMsi) { Write-Host "Removing MSI package: $($installedMsi.ProductCode)" @@ -59,13 +61,45 @@ 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 } } +} + +if ($WslaPackage) { + RemoveMSI -MSIDataRegistryPath "HKLM:Software\Microsoft\Windows\CurrentVersion\WSLA\MSI" + + # msiexec.exe is very picky about path formats, so use the canonical path + $WslaPackage = Resolve-Path $WslaPackage + + Write-Host "Installing MSI package: $WslaPackage" + $MSIArguments = @( + "/norestart" + "/qn" + "/i" + $WslaPackage + ) + + $exitCode = (Start-Process -Wait "msiexec.exe" -ArgumentList $MSIArguments -NoNewWindow -PassThru).ExitCode + if ($exitCode -Ne 0) + { + Write-Host "Failed to remove package: $exitCode" + exit 1 + } +} + +if ($Package) { + $installedPackage = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemforLinux -AllUsers + if ($installedPackage) { + Write-Host "Removing previous package installation" + Remove-AppxPackage $installedPackage -AllUsers + } + + RemoveMSI -MSIDataRegistryPath "HKLM:Software\Microsoft\Windows\CurrentVersion\Lxss\MSI" Write-Host "Installing package: $Package" try { diff --git a/tools/test/test.bat.in b/tools/test/test.bat.in index 76fb59a43..c0b92c017 100644 --- a/tools/test/test.bat.in +++ b/tools/test/test.bat.in @@ -6,7 +6,7 @@ set "Bin=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}\${CMAKE_BUILD_TYPE}" set "Tools=${CMAKE_CURRENT_LIST_DIR}\tools" path %PATH%;${TAEF_SOURCE_DIR}\build\Binaries\${TARGET_PLATFORM} -powershell.exe -ExecutionPolicy Bypass "%tools%\test\run-tests.ps1" -SetupScript "%tools%\test\test-setup.ps1" -DistroPath "${TEST_DISTRO_SOURCE_DIR}test_distro.tar.xz" -TestDataPath "${WSL_TEST_DATA_SOURCE_DIR}" -TestDllPath "%bin%\wsltests.dll" -UnitTestsPath "${CMAKE_CURRENT_LIST_DIR}\test\linux\unit_tests" -Package "%bin%\installer.msix" %* || goto fail +powershell.exe -ExecutionPolicy Bypass "%tools%\test\run-tests.ps1" -SetupScript "%tools%\test\test-setup.ps1" -DistroPath "${TEST_DISTRO_SOURCE_DIR}test_distro.tar.xz" -TestDataPath "${WSL_TEST_DATA_SOURCE_DIR}" -TestDllPath "%bin%\wsltests.dll" -UnitTestsPath "${CMAKE_CURRENT_LIST_DIR}\test\linux\unit_tests" -Package "%bin%\installer.msix" -WslaPackage "%bin%\wsla.msi" %* || goto fail exit /b 0 diff --git a/wslamsi/CMakeLists.txt b/wslamsi/CMakeLists.txt new file mode 100644 index 000000000..9fc6b0015 --- /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}/wslamsi.wix.in) +set(PACKAGE_WIX ${BIN}/wslamsi.wix) +set(CAB_CACHE ${BIN}/cab) +set(BINARIES wslaservice.exe;wslaserviceproxystub.dll;wsladiag.exe;wslrelay.exe;wsldevicehost.dll) + +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 wslrelay) + +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/wslamsi.wix.in b/wslamsi/wslamsi.wix.in new file mode 100644 index 000000000..1d231625b --- /dev/null +++ b/wslamsi/wslamsi.wix.in @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +