Skip to content

Commit 5acd600

Browse files
benhillisBen Hillis
andauthored
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>
1 parent 25572cc commit 5acd600

File tree

3 files changed

+67
-37
lines changed

3 files changed

+67
-37
lines changed

.pipelines/build-stage.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ parameters:
2424
type: object
2525
default:
2626
- 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"
2828
- target: "msixgluepackage"
2929
pattern: "gluepackage.msix"
3030
- target: "msipackage"
@@ -120,6 +120,11 @@ stages:
120120
ob_sdl_codeSignValidation_excludes: -|**testbin\**
121121
Codeql.PublishDatabaseLog: true
122122
Codeql.SourceRoot: src
123+
packageStagingDir: '$(Build.SourcesDirectory)\packageStagingDir'
124+
${{ if eq(parameters.isRelease, 'true') }}:
125+
packageInputDirArg: '-DPACKAGE_INPUT_DIR=$(packageStagingDir)'
126+
${{ else }}:
127+
packageInputDirArg: ''
123128

124129
steps:
125130

@@ -166,7 +171,7 @@ stages:
166171
displayName: "CMake ${{ platform }}"
167172
inputs:
168173
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 }}
170175

171176
# This additional Restore NuGet package task is added as a workaround for WSL Settings to have its packages restored properly.
172177
# Without this, building wsl settings may encounter the following error:
@@ -196,7 +201,7 @@ stages:
196201
AuthSignCertName: ${{ parameters.esrp.AuthSignCertName }}
197202
AppRegistrationClientId: ${{ parameters.esrp.AppRegistrationClientId }}
198203
AppRegistrationTenantId: ${{ parameters.esrp.AppRegistrationTenantId }}
199-
FolderPath: "bin\\${{ platform }}"
204+
FolderPath: "bin\\${{ platform }}\\Release"
200205
Pattern: "${{ target.pattern }}"
201206
UseMSIAuthentication: true
202207
EsrpClientId: ${{ parameters.esrp.EsrpClientId }}
@@ -224,20 +229,27 @@ stages:
224229
}
225230
]
226231
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+
}
241253
242254
- script: cmake --build . --config Release -- -m
243255
displayName: "Build installer msix and tests (${{ platform }})"
@@ -411,3 +423,4 @@ stages:
411423

412424
- task: CodeQL3000Finalize@0
413425
condition: ${{ and(parameters.isNightly, eq(variables['Build.SourceBranch'], 'refs/heads/main'))}}
426+

msipackage/CMakeLists.txt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
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+
211
set(OUTPUT_PACKAGE ${BIN}/wsl.msi)
312
set(PACKAGE_WIX_IN ${CMAKE_CURRENT_LIST_DIR}/package.wix.in)
413
set(PACKAGE_WIX ${BIN}/package.wix)
514
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)
816
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")
1018
endif()
1119

1220
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})
1427
list(APPEND BINARIES_DEPENDENCIES "${BIN}/${binary}")
1528
endforeach()
1629

msipackage/package.wix.in

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
22
<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}">
33
<MajorUpgrade AllowDowngrades="yes" Disallow="no" />
44
<MediaTemplate EmbedCab="yes" />
@@ -19,21 +19,21 @@
1919
<DirectoryRef Id="INSTALLDIR">
2020
<Component Id="wsl" Guid="F0C8D6BA-1502-41E7-BF72-D93DFA134730" UninstallWhenSuperseded="yes" DisableRegistryReflection="yes" Bitness="always64">
2121
<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">
2323
<Shortcut Id="WSLShortcut" Name="WSL" Description="Windows Subsystem for Linux" Arguments="--cd ~" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico">
2424
<ShortcutProperty Key="System.AppUserModel.ID" Value="Microsoft.WSL"/>
2525
<ShortcutProperty Key="System.AppUserModel.ToastActivatorCLSID" Value="{2B9C59C3-98F1-45C8-B87B-12AE3C7927E8}"/>
2626
</Shortcut>
2727
</File>
2828

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" />
3434

3535
<?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" />
3737
<?endif?>
3838

3939
<?if "${WSL_DEV_BINARY_PATH}" = "" ?>
@@ -223,7 +223,7 @@
223223
</RegistryKey>
224224

225225
<!-- 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" />
227227
<ServiceInstall Name="WSLService" DisplayName="WSL Service" Description="WSL Service" Start="auto" Type="ownProcess" ErrorControl="normal" Account="LocalSystem" Vital="yes" Interactive="no" />
228228

229229
<!-- The service is stopped on uninstall and upgrade.
@@ -241,8 +241,8 @@
241241
<File Id="rdpnanoTransport.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" />
242242
<File Id="RdpWinStlHelper.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" />
243243
<?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}" />
246246

247247
<!-- MSRDC Plugin registration -->
248248
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Terminal Server Client\Default\OptionalAddIns\WSLDVC_PACKAGE">
@@ -292,7 +292,7 @@
292292
<ComponentGroup Id="wslsettings" Directory="WSLSETTINGS" Source="${BIN}/wslsettings">
293293
<Component Id="wslsettingsnonserver" Guid="AB166073-8855-492B-95C8-C6E5939B66A5" Bitness="always64" DisableRegistryReflection="yes" UninstallWhenSuperseded="yes" Condition="MsiNTProductType = 1">
294294
<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">
296296
<Shortcut Id="WSLSettingsShortcutNonServer" Name="WSL Settings" Description="Windows Subsystem for Linux Settings" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico">
297297
<ShortcutProperty Key="System.AppUserModel.IsSystemComponent" Value="true"/>
298298
</Shortcut>
@@ -323,7 +323,7 @@
323323
</Component>
324324
<Component Id="wslsettingsserver" Guid="EE2D69A0-4F55-4EC5-9576-4FAD70BC798E" Bitness="always64" DisableRegistryReflection="yes" UninstallWhenSuperseded="yes" Condition="MsiNTProductType &gt; 1">
325325
<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">
327327
<Shortcut Id="WSLSettingsShortcutServer" Name="WSL Settings" Description="Windows Subsystem for Linux Settings" Advertise="yes" Directory="ProgramMenuFolder" Icon="wsl.ico"/>
328328
</File>
329329
<!-- Protocol registration -->
@@ -350,7 +350,10 @@
350350
</RegistryKey>
351351
</RegistryKey>
352352
</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>
354357
<Files Include="*.exe">
355358
<Exclude Files="wslsettings.exe" />
356359
</Files>
@@ -385,8 +388,8 @@
385388

386389
</Feature>
387390

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"/>
390393

391394
<CustomAction Id="ValidateInstall"
392395
Impersonate="no"
@@ -559,3 +562,4 @@
559562
<Property Id="MSIRMSHUTDOWN" Value="0" Secure="yes" />
560563
</Package>
561564
</Wix>
565+

0 commit comments

Comments
 (0)