CI: update issue for wslsettings being rebuilt and signature being overwritten (#13855)
* CI: resolve wslsettings being rebuilt and signature being overwritten * fix for non-release builds * fix yaml format * remove print for local builds --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Ben Hillis committed
Dec 10, 2025 at 16:20 UTC
5acd6004641ee063ed4d3043db6c6f919aaabda2
3 files changed
+67
-37
.pipelines/build-stage.yml
+30
-17
@@ -24,7 +24,7 @@ parameters:
24
type: object
25
default:
26
- target: "wsl;libwsl;wslg;wslservice;wslhost;wslrelay;wslinstaller;wslinstall;initramfs;wslserviceproxystub;wslsettings;wslinstallerproxystub;testplugin"
27
- pattern: "wsl.exe,libwsl.dll,wslg.exe,wslservice.exe,wslhost.exe,wslrelay.exe,wslinstaller.exe,wslinstall.dll,wslserviceproxystub.dll,wslsettings.dll,wslsettings.exe,wslinstallerproxystub.dll,wsldevicehost.dll,WSLDVCPlugin.dll,testplugin.dll,wsldeps.dll"
27
+ pattern: "wsl.exe,libwsl.dll,wslg.exe,wslservice.exe,wslhost.exe,wslrelay.exe,wslinstaller.exe,wslinstall.dll,wslserviceproxystub.dll,wslsettings/wslsettings.dll,wslsettings/wslsettings.exe,wslinstallerproxystub.dll,wsldevicehost.dll,WSLDVCPlugin.dll,testplugin.dll,wsldeps.dll"
28
- target: "msixgluepackage"
29
pattern: "gluepackage.msix"
30
- target: "msipackage"
@@ -120,6 +120,11 @@ stages:
120
ob_sdl_codeSignValidation_excludes: -|**testbin\**
121
Codeql.PublishDatabaseLog: true
122
Codeql.SourceRoot: src
123
+ packageStagingDir: '$(Build.SourcesDirectory)\packageStagingDir'
124
+ ${{ if eq(parameters.isRelease, 'true') }}:
125
+ packageInputDirArg: '-DPACKAGE_INPUT_DIR=$(packageStagingDir)'
126
+ ${{ else }}:
127
+ packageInputDirArg: ''
128
129
steps:
130
@@ -166,7 +171,7 @@ stages:
171
displayName: "CMake ${{ platform }}"
172
inputs:
173
workingDirectory: "."
169
- cmakeArgs: . --fresh -A ${{ platform }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DPACKAGE_VERSION=$(version.WSL_PACKAGE_VERSION) -DWSL_NUGET_PACKAGE_VERSION=$(version.WSL_NUGET_PACKAGE_VERSION) -DSKIP_PACKAGE_SIGNING=${{ parameters.isRelease }} -DOFFICIAL_BUILD=${{ parameters.isRelease }} -DPIPELINE_BUILD_ID=$(Build.BuildId) -DVSO_ORG=${{ parameters.vsoOrg }} -DVSO_PROJECT=${{ parameters.vsoProject }} -DWSL_BUILD_WSL_SETTINGS=true
174
+ cmakeArgs: . --fresh -A ${{ platform }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DPACKAGE_VERSION=$(version.WSL_PACKAGE_VERSION) -DWSL_NUGET_PACKAGE_VERSION=$(version.WSL_NUGET_PACKAGE_VERSION) -DSKIP_PACKAGE_SIGNING=${{ parameters.isRelease }} -DOFFICIAL_BUILD=${{ parameters.isRelease }} -DPIPELINE_BUILD_ID=$(Build.BuildId) -DVSO_ORG=${{ parameters.vsoOrg }} -DVSO_PROJECT=${{ parameters.vsoProject }} -DWSL_BUILD_WSL_SETTINGS=true $(packageInputDirArg)\${{ platform }}
175
176
# This additional Restore NuGet package task is added as a workaround for WSL Settings to have its packages restored properly.
177
# Without this, building wsl settings may encounter the following error:
@@ -196,7 +201,7 @@ stages:
201
AuthSignCertName: ${{ parameters.esrp.AuthSignCertName }}
202
AppRegistrationClientId: ${{ parameters.esrp.AppRegistrationClientId }}
203
AppRegistrationTenantId: ${{ parameters.esrp.AppRegistrationTenantId }}
199
- FolderPath: "bin\\${{ platform }}"
204
+ FolderPath: "bin\\${{ platform }}\\Release"
205
Pattern: "${{ target.pattern }}"
206
UseMSIAuthentication: true
207
EsrpClientId: ${{ parameters.esrp.EsrpClientId }}
@@ -224,20 +229,27 @@ stages:
229
}
230
]
231
227
- # Replace the intermediate wslsettings binaries file with the signed versions so that any future steps building wslsettings will use the signed versions
228
- - task: PowerShell@2
229
- displayName: 'Replace wslsettings binaries in intermediate folder with signed versions'
230
- condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
231
- inputs:
232
- targetType: inline
233
- script: |
234
- $arch = '${{ platform }}'
235
- $wslsettingsbinpath = "bin\$arch\release\wslsettings"
236
- $wslsettingsobjpath = "src\windows\wslsettings\obj\$arch\release"
237
- # Update the timestamp of wslsettings.exe so that it doesn't get rebuilt
238
- (Get-Item $wslsettingsbinpath\wslsettings.exe).LastWriteTime = Get-Date
239
- Copy-Item $wslsettingsbinpath\wslsettings.dll $wslsettingsobjpath\wslsettings.dll -Force
240
- Copy-Item $wslsettingsbinpath\wslsettings.exe $wslsettingsobjpath\apphost.exe -Force
232
+ - task: PowerShell@2
233
+ displayName: "Copy signed ${{ target.target }} to staging (${{ platform }})"
234
+ condition: and(succeeded(), eq('${{ parameters.isRelease }}', true))
235
+ inputs:
236
+ targetType: inline
237
+ script: |
238
+ $arch = '${{ platform }}'
239
+ $pattern = '${{ target.pattern }}'
240
+ $inputDir = "bin\$arch\Release"
241
+ $outputDir = "$(packageStagingDir)\$arch"
242
+ New-Item -ItemType Directory -Path "$outputDir\wslsettings" -Force
243
+ foreach ($file in $pattern.Split(',')) {
244
+ $sourcePath = Join-Path $inputDir $file
245
+ if (Test-Path $sourcePath) {
246
+ $destPath = Join-Path $outputDir $file
247
+ Write-Host "Copying signed file: $sourcePath -> $destPath"
248
+ Copy-Item -Path $sourcePath -Destination $destPath -Force
249
+ } else {
250
+ Write-Warning "File not found: $sourcePath"
251
+ }
252
+ }
253
254
- script: cmake --build . --config Release -- -m
255
displayName: "Build installer msix and tests (${{ platform }})"
@@ -411,3 +423,4 @@ stages:
423
424
- task: CodeQL3000Finalize@0
425
condition: ${{ and(parameters.isNightly, eq(variables['Build.SourceBranch'], 'refs/heads/main'))}}
426
+
msipackage/CMakeLists.txt
+17
-4
@@ -1,16 +1,29 @@
1
set(BIN ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
2
+
3
+# For pipeline builds, use PACKAGE_INPUT_DIR if specified (contains signed binaries)
4
+# For local builds, use bin directory
5
+if(DEFINED PACKAGE_INPUT_DIR)
6
+ message(STATUS "Using signed binaries from ${PACKAGE_INPUT_DIR} for MSI packaging")
7
+else()
8
+ set(PACKAGE_INPUT_DIR ${BIN})
9
+endif()
10
+
11
set(OUTPUT_PACKAGE ${BIN}/wsl.msi)
12
set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/package.wix.in)
13
set(PACKAGE_WIX ${BIN}/package.wix)
14
set(CAB_CACHE ${BIN}/cab)
6
-set(BINARIES wsl.exe;wslg.exe;wslhost.exe;wslrelay.exe;wslservice.exe;wslserviceproxystub.dll;init;initrd.img;wslinstall.dll)
7
-
15
+set(WINDOWS_BINARIES wsl.exe;wslg.exe;wslhost.exe;wslrelay.exe;wslservice.exe;wslserviceproxystub.dll;wslinstall.dll)
16
if (WSL_BUILD_WSL_SETTINGS)
9
- list(APPEND BINARIES_DEPENDENCIES "wslsettings/wslsettings.dll;wslsettings/wslsettings.exe;libwsl.dll")
17
+ list(APPEND WINDOWS_BINARIES "wslsettings/wslsettings.dll;wslsettings/wslsettings.exe;libwsl.dll")
18
endif()
19
20
set(BINARIES_DEPENDENCIES)
13
-foreach(binary ${BINARIES})
21
+foreach(binary ${WINDOWS_BINARIES})
22
+ list(APPEND BINARIES_DEPENDENCIES "${PACKAGE_INPUT_DIR}/${binary}")
23
+endforeach()
24
+
25
+set(LINUX_BINARIES init;initrd.img)
26
+foreach(binary ${LINUX_BINARIES})
27
list(APPEND BINARIES_DEPENDENCIES "${BIN}/${binary}")
28
endforeach()
29
msipackage/package.wix.in
+20
-16
@@ -1,4 +1,4 @@
1
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
1
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2
<Package Name="Windows Subsystem for Linux" Language="1033" InstallerVersion="500" Version="${PACKAGE_VERSION}" Manufacturer="Microsoft Corporation" UpgradeCode="6D5B792B-1EDC-4DE9-8EAD-201B820F8E82" Scope="perMachine" Compressed="${COMPRESS_PACKAGE}">
3
<MajorUpgrade AllowDowngrades="yes" Disallow="no" />
4
<MediaTemplate EmbedCab="yes" />
@@ -19,21 +19,21 @@
19
<DirectoryRef Id="INSTALLDIR">
20
<Component Id="wsl" Guid="F0C8D6BA-1502-41E7-BF72-D93DFA134730" UninstallWhenSuperseded="yes" DisableRegistryReflection="yes" Bitness="always64">
21
<RemoveFile Id="CleanUpWSLShortCut" Directory="ProgramMenuFolder" Name="WSL" On="uninstall"/>
22
- <File Id="wsl.exe" Name="wsl.exe" Source="${BIN}/wsl.exe" KeyPath="yes">
22
+ <File Id="wsl.exe" Name="wsl.exe" Source="${PACKAGE_INPUT_DIR}/wsl.exe" KeyPath="yes">
23
<Shortcut Id="WSLShortcut" Name="WSL" Description="Windows Subsystem for Linux" Arguments="--cd ~" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico">
24
<ShortcutProperty Key="System.AppUserModel.ID" Value="Microsoft.WSL"/>
25
<ShortcutProperty Key="System.AppUserModel.ToastActivatorCLSID" Value="{2B9C59C3-98F1-45C8-B87B-12AE3C7927E8}"/>
26
</Shortcut>
27
</File>
28
29
- <File Id="wslg.exe" Name="wslg.exe" Source="${BIN}/wslg.exe" />
30
- <File Id="wslhost.exe" Name="wslhost.exe" Source="${BIN}/wslhost.exe" />
31
- <File Id="wslrelay.exe" Name="wslrelay.exe" Source="${BIN}/wslrelay.exe" />
32
- <File Id="wslserviceproxystub.dll" Name="wslserviceproxystub.dll" Source="${BIN}/wslserviceproxystub.dll" />
33
- <File Id="wsldeps.dll" Name="wsldeps.dll" Source="${BIN}/wsldeps.dll" />
29
+ <File Id="wslg.exe" Name="wslg.exe" Source="${PACKAGE_INPUT_DIR}/wslg.exe" />
30
+ <File Id="wslhost.exe" Name="wslhost.exe" Source="${PACKAGE_INPUT_DIR}/wslhost.exe" />
31
+ <File Id="wslrelay.exe" Name="wslrelay.exe" Source="${PACKAGE_INPUT_DIR}/wslrelay.exe" />
32
+ <File Id="wslserviceproxystub.dll" Name="wslserviceproxystub.dll" Source="${PACKAGE_INPUT_DIR}/wslserviceproxystub.dll" />
33
+ <File Id="wsldeps.dll" Name="wsldeps.dll" Source="${PACKAGE_INPUT_DIR}/wsldeps.dll" />
34
35
<?if "${WSL_BUILD_WSL_SETTINGS}" = "true" ?>
36
- <File Id="libwsl.dll" Name="libwsl.dll" Source="${BIN}/libwsl.dll" />
36
+ <File Id="libwsl.dll" Name="libwsl.dll" Source="${PACKAGE_INPUT_DIR}/libwsl.dll" />
37
<?endif?>
38
39
<?if "${WSL_DEV_BINARY_PATH}" = "" ?>
@@ -223,7 +223,7 @@
223
</RegistryKey>
224
225
<!-- Session 0 service -->
226
- <File Id="wslservice.exe" Source="${BIN}/wslservice.exe" KeyPath="yes" />
226
+ <File Id="wslservice.exe" Source="${PACKAGE_INPUT_DIR}/wslservice.exe" KeyPath="yes" />
227
<ServiceInstall Name="WSLService" DisplayName="WSL Service" Description="WSL Service" Start="auto" Type="ownProcess" ErrorControl="normal" Account="LocalSystem" Vital="yes" Interactive="no" />
228
229
<!-- The service is stopped on uninstall and upgrade.
@@ -241,8 +241,8 @@
241
<File Id="rdpnanoTransport.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" />
242
<File Id="RdpWinStlHelper.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" />
243
<?endif?>
244
- <File Id="wsldevicehost.dll" Source="${BIN}/wsldevicehost.dll" />
245
- <File Id="${WSLG_TS_PLUGIN_DLL}" Source="${BIN}/${WSLG_TS_PLUGIN_DLL}" />
244
+ <File Id="wsldevicehost.dll" Source="${PACKAGE_INPUT_DIR}/wsldevicehost.dll" />
245
+ <File Id="${WSLG_TS_PLUGIN_DLL}" Source="${PACKAGE_INPUT_DIR}/${WSLG_TS_PLUGIN_DLL}" />
246
247
<!-- MSRDC Plugin registration -->
248
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE">
@@ -292,7 +292,7 @@
292
<ComponentGroup Id="wslsettings" Directory="WSLSETTINGS" Source="${BIN}/wslsettings">
293
<Component Id="wslsettingsnonserver" Guid="AB166073-8855-492B-95C8-C6E5939B66A5" Bitness="always64" DisableRegistryReflection="yes" UninstallWhenSuperseded="yes" Condition="MsiNTProductType = 1">
294
<RemoveFile Id="CleanUpWSLSettingsShortCutNonServer" Directory="ProgramMenuFolder" Name="WSLSettings" On="uninstall"/>
295
- <File Id="wslsettings.exe_nonserver" Source="${BIN}/wslsettings/wslsettings.exe" KeyPath="yes" ShortName="kyk8fs6a.exe">
295
+ <File Id="wslsettings.exe_nonserver" Source="${PACKAGE_INPUT_DIR}/wslsettings/wslsettings.exe" KeyPath="yes" ShortName="kyk8fs6a.exe">
296
<Shortcut Id="WSLSettingsShortcutNonServer" Name="WSL Settings" Description="Windows Subsystem for Linux Settings" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico">
297
<ShortcutProperty Key="System.AppUserModel.IsSystemComponent" Value="true"/>
298
</Shortcut>
@@ -323,7 +323,7 @@
323
</Component>
324
<Component Id="wslsettingsserver" Guid="EE2D69A0-4F55-4EC5-9576-4FAD70BC798E" Bitness="always64" DisableRegistryReflection="yes" UninstallWhenSuperseded="yes" Condition="MsiNTProductType > 1">
325
<RemoveFile Id="CleanUpWSLSettingsShortCutServer" Directory="ProgramMenuFolder" Name="WSLSettings" On="uninstall"/>
326
- <File Id="wslsettings.exe_server" Source="${BIN}/wslsettings/wslsettings.exe" KeyPath="yes" ShortName="kyk8fs6b.exe">
326
+ <File Id="wslsettings.exe_server" Source="${PACKAGE_INPUT_DIR}/wslsettings/wslsettings.exe" KeyPath="yes" ShortName="kyk8fs6b.exe">
327
<Shortcut Id="WSLSettingsShortcutServer" Name="WSL Settings" Description="Windows Subsystem for Linux Settings" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico"/>
328
</File>
329
<!-- Protocol registration -->
@@ -350,7 +350,10 @@
350
</RegistryKey>
351
</RegistryKey>
352
</Component>
353
- <Files Include="*.dll"/>
353
+ <File Id="wslsettings.dll" Source="${PACKAGE_INPUT_DIR}/wslsettings/wslsettings.dll"/>
354
+ <Files Include="*.dll">
355
+ <Exclude Files="wslsettings.dll" />
356
+ </Files>
357
<Files Include="*.exe">
358
<Exclude Files="wslsettings.exe" />
359
</Files>
@@ -385,8 +388,8 @@
388
389
</Feature>
390
388
- <Binary Id="wslinstall.dll" SourceFile="${BIN}/wslinstall.dll" />
389
- <Binary Id="msixpackage" SourceFile="${BIN}/gluepackage.msix"/>
391
+ <Binary Id="wslinstall.dll" SourceFile="${PACKAGE_INPUT_DIR}/wslinstall.dll" />
392
+ <Binary Id="msixpackage" SourceFile="${PACKAGE_INPUT_DIR}/gluepackage.msix"/>
393
394
<CustomAction Id="ValidateInstall"
395
Impersonate="no"
@@ -559,3 +562,4 @@
562
<Property Id="MSIRMSHUTDOWN" Value="0" Secure="yes" />
563
</Package>
564
</Wix>
565
+