Skip to content

Commit f9f1c38

Browse files
benhillisBen Hillis
andauthored
devicehost: stop re-signing and fix MSI installer failing to replace wsldevicehost.dll (#40075)
* devicehost: stop re-signing and fix MSI installer failing to replace wsldevicehost.dll * pr feedback * use MSIRMSHUTDOWN = 1 instead of custom action --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
1 parent f8e579a commit f9f1c38

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.pipelines/build-stage.yml

Lines changed: 1 addition & 1 deletion
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/wslsettings.dll,wslsettings/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,WSLDVCPlugin.dll,testplugin.dll,wsldeps.dll"
2828
- target: "msixgluepackage"
2929
pattern: "gluepackage.msix"
3030
- target: "msipackage"

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ set (GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
157157
file(MAKE_DIRECTORY ${GENERATED_DIR})
158158

159159
set(PACKAGE_CERTIFICATE ${GENERATED_DIR}/dev-cert.pfx)
160-
file(CREATE_LINK ${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}/wsldevicehost.dll ${BIN}/wsldevicehost.dll)
161160
file(CREATE_LINK ${WSLG_SOURCE_DIR}/${TARGET_PLATFORM}/${WSLG_TS_PLUGIN_DLL} ${BIN}/${WSLG_TS_PLUGIN_DLL})
162161
file(CREATE_LINK ${WSLDEPS_SOURCE_DIR}/bin/wsldeps.dll ${BIN}/wsldeps.dll)
163162

msipackage/package.wix.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@
221221
N.B. It shouldn't be started on install because it will fail to start if the OC is missing,
222222
which would fail the install. -->
223223
<ServiceControl Id="StopService" Stop="both" Remove="uninstall" Name="WSLService" Wait="yes" />
224+
225+
<File Id="wsldevicehost.dll" Source="${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}/wsldevicehost.dll" />
224226
</Component>
225227

226228
<Component Id="wslg" Guid="F0C8D6BA-1502-41E7-BF72-D93DFA134731" UninstallWhenSuperseded="yes" DisableRegistryReflection="yes" Bitness="always64">
@@ -232,7 +234,6 @@
232234
<File Id="rdpnanoTransport.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/rdpnanoTransport.dll" />
233235
<File Id="RdpWinStlHelper.dll" Source="${MSRDC_SOURCE_DIR}/${TARGET_PLATFORM}/RdpWinStlHelper.dll" />
234236
<?endif?>
235-
<File Id="wsldevicehost.dll" Source="${PACKAGE_INPUT_DIR}/wsldevicehost.dll" />
236237
<File Id="${WSLG_TS_PLUGIN_DLL}" Source="${PACKAGE_INPUT_DIR}/${WSLG_TS_PLUGIN_DLL}" />
237238

238239
<!-- MSRDC Plugin registration -->
@@ -551,7 +552,7 @@
551552
<!-- Force all applications to exit during upgrade.
552553
See: https://learn.microsoft.com/en-us/windows/win32/msi/msirmshutdown
553554
-->
554-
<Property Id="MSIRMSHUTDOWN" Value="0" Secure="yes" />
555+
<Property Id="MSIRMSHUTDOWN" Value="1" Secure="yes" />
555556
</Package>
556557
</Wix>
557558

packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<package id="Microsoft.WSL.bsdtar" version="0.0.2-2" />
1919
<package id="Microsoft.WSL.Dependencies.amd64fre" version="10.0.27820.1000-250318-1700.rs-base2-hyp" targetFramework="native" />
2020
<package id="Microsoft.WSL.Dependencies.arm64fre" version="10.0.27820.1000-250318-1700.rs-base2-hyp" targetFramework="native" />
21-
<package id="Microsoft.WSL.DeviceHost" version="1.1.48-0" />
21+
<package id="Microsoft.WSL.DeviceHost" version="1.2.10-0" />
2222
<package id="Microsoft.WSL.Kernel" version="6.6.114.1-1" targetFramework="native" />
2323
<package id="Microsoft.WSL.LinuxSdk" version="1.20.0" targetFramework="native" />
2424
<package id="Microsoft.WSL.TestDistro" version="2.7.1-1" />

test/windows/InstallerTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,17 @@ class InstallerTests
175175
return wsl::windows::common::registry::ReadString(m_lxssKey.get(), L"MSI", L"ProductCode", L"");
176176
}
177177

178+
// Release any in-process COM DLLs (e.g. wslserviceproxystub.dll loaded by prior tests)
179+
// so the Restart Manager doesn't detect the test process as holding files.
180+
// This avoids install failures on older Server SKUs where the RM has stricter silent-mode behavior.
181+
static void PrepareForMsiOperation()
182+
{
183+
CoFreeUnusedLibrariesEx(0, 0);
184+
}
185+
178186
void UninstallMsi()
179187
{
188+
PrepareForMsiOperation();
180189
auto productCode = GetMsiProductCode();
181190
VERIFY_IS_FALSE(productCode.empty());
182191

@@ -185,6 +194,7 @@ class InstallerTests
185194

186195
void InstallMsi()
187196
{
197+
PrepareForMsiOperation();
188198
CallMsiExec(std::format(L"/qn /norestart /i {} /L*V {}", m_msiPath, GenerateMsiLogPath()));
189199
}
190200

@@ -367,6 +377,7 @@ class InstallerTests
367377
LogInfo("Installing: %ls", installerFile.c_str());
368378
if (wsl::shared::string::EndsWith<wchar_t>(installerFile, L".msi"))
369379
{
380+
PrepareForMsiOperation();
370381
CallMsiExec(std::format(L"/qn /norestart /i {} /L*V {}", installerFile, GenerateMsiLogPath()));
371382
}
372383
else

0 commit comments

Comments
 (0)