Skip to content

WSLC SDK install API update#40949

Open
JohnMcPMS wants to merge 10 commits into
microsoft:masterfrom
JohnMcPMS:install-api-update
Open

WSLC SDK install API update#40949
JohnMcPMS wants to merge 10 commits into
microsoft:masterfrom
JohnMcPMS:install-api-update

Conversation

@JohnMcPMS

Copy link
Copy Markdown
Member

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Changes WslcInstallWithDependencies to 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:

[old]
WslcGetMissingComponents -> get component flags enum
if missing components :: WslcInstallWithDependencies

[new]
WslcGetMissingComponents -> get component flags enum
if no missing components, optionally :: WslcGetVersion -> check that WSLC version supports all needed features, if needed add WSL_PACKAGE to the components
if missing components :: WslcInstallWithDependencies(components)

[also new]
something isn't working :: WslcInstallWithDependencies(WSL_PACKAGE, REPAIR) to force reinstall

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 WslcInstallWithDependencies that forces a GH fallback update that is intentionally blocked by the test.

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner June 30, 2026 00:58
Copilot AI review requested due to automatic review settings June 30, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InstallOptions runtimeclass and updates WslcService::InstallWithDependencies{Async} to accept options and map them to the C API.
  • Refactors WindowsUpdateContext to 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.

Comment thread test/windows/WslcSdkTests.cpp
Comment thread src/windows/WslcSDK/wslcsdk.h
Comment thread src/windows/WslcSDK/winrt/wslcsdk.idl
Comment thread src/windows/WslcSDK/wslcsdk.cpp
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage),
TraceLoggingBool(forceInstall, "forceInstall"));
TraceLoggingBool(options == UpdateOptions::ResetProductRegistration, "forceInstall"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread test/windows/Common.cpp
m_process = LxsstuStartProcess(cmd.data());
}

UniqueWebServer::UniqueWebServer(LPCWSTR Endpoint, UINT StatusCode)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants