WSLC SDK install API update#40949
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the WSLC SDK install/update surface to support caller-selected component installation plus “repair” semantics (reinstall/force-update), and threads those options through the WinRT projection and Windows Update integration helpers.
Changes:
- Extends the C SDK install entry point to accept explicit component flags and install options (including repair).
- Adds a WinRT
InstallOptionsruntimeclass and updatesWslcService::InstallWithDependencies{Async}to accept options and map them to the C API. - Refactors
WindowsUpdateContextto support “ensure vs reset” product registration and updates tests/utilities accordingly.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WslcSdkWinRTTests.cpp | Updates WinRT install tests and adds coverage for InstallOptions defaults/mutations and error behavior. |
| test/windows/WslcSdkTests.cpp | Adds C SDK install tests for new flags/options and a GH-fallback failure scenario. |
| test/windows/WindowsUpdateTests.cpp | Updates tests for the new WindowsUpdateContext constructor and RunUpdateFlow options. |
| test/windows/Common.h | Extends UniqueWebServer with a status-code-only response mode for negative-path tests. |
| test/windows/Common.cpp | Implements UniqueWebServer status-code-only constructor using HttpListener. |
| src/windows/WslcSDK/wslcsdk.h | Introduces WslcInstallOptions and changes the C install API signature to accept components/options. |
| src/windows/WslcSDK/wslcsdk.cpp | Updates install implementation to support explicit components and repair semantics via Windows Update options. |
| src/windows/WslcSDK/winrt/WslcService.h | Changes WinRT install methods to accept InstallOptions. |
| src/windows/WslcSDK/winrt/WslcService.cpp | Maps WinRT InstallOptions to C flags/options and forwards into the updated C API. |
| src/windows/WslcSDK/winrt/wslcsdk.idl | Adds InstallOptions runtimeclass and updates the WslcService install method signatures. |
| src/windows/WslcSDK/winrt/InstallOptions.h | Adds WinRT implementation type for InstallOptions. |
| src/windows/WslcSDK/winrt/InstallOptions.cpp | Implements InstallOptions property storage. |
| src/windows/WslcSDK/winrt/CMakeLists.txt | Adds InstallOptions sources to the WinRT build. |
| src/windows/common/WindowsUpdateIntegration.h | Refactors Windows Update flow to use UpdateOptions and adds reset capability to product registration. |
| src/windows/common/WindowsUpdateIntegration.cpp | Implements reset-aware product registration and updates update-flow tracing/logic. |
| src/windows/common/helpers.hpp | Declares VersionRegisteredWithDcat() helper. |
| src/windows/common/helpers.cpp | Implements VersionRegisteredWithDcat() and uses a constant for the DCAT version value name. |
| TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), | ||
| TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), | ||
| TraceLoggingBool(forceInstall, "forceInstall")); | ||
| TraceLoggingBool(options == UpdateOptions::ResetProductRegistration, "forceInstall"), |
There was a problem hiding this comment.
Should we just log the options value directly ?
| progressCallback(WSLC_COMPONENT_FLAG_VIRTUAL_MACHINE_PLATFORM, 1, 1, context); | ||
| } | ||
|
|
||
| // If a reboot is required, we need the reboot to happen before attempting to install the WSL package. |
There was a problem hiding this comment.
That's not necessarily true (the MSI can be installed before reboot). From a UX perspective, I think installing the dependencies and then returning ERROR_SUCCESS_REBOOT_REQUIRED is nicer, since one rebooted, everything will be ready for use
| m_process = LxsstuStartProcess(cmd.data()); | ||
| } | ||
|
|
||
| UniqueWebServer::UniqueWebServer(LPCWSTR Endpoint, UINT StatusCode) |
There was a problem hiding this comment.
nit: I think we could merge this with the UniqueWebServer(LPCWSTR Endpoint, LPCWSTR Content) overload (we could add an optional StatusCode argument which defaults to 200)
Summary of the Pull Request
Updates the WSLC SDK install API to allow more flexibility in the calling pattern, specifically enabling caller-initiated updates/reinstalls to WSL even when WSLC is already present.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Changes
WslcInstallWithDependenciesto take in a component flags and new options enum values. This allows the caller to request specific components to install and to request repair semantics, where we will attempt to install the latest version even if it appears that this version is already present.The call flow is not significantly affected, although the pattern can now support additional checks:
Similar changes are made to the WinRT API surface, with more flexibility to simply not provide some of the inputs and we will make the calls as we would have previously.
Validation Steps Performed
Ran all modified and new tests.
Adds a new test for
WslcInstallWithDependenciesthat forces a GH fallback update that is intentionally blocked by the test.