Skip to content

WSLC SDK install API update#40949

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

WSLC SDK install API update#40949
JohnMcPMS wants to merge 9 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 on lines +1550 to +1561
constexpr auto GitHubApiResponse =
LR"([{
\"name\": \"1.0.0\",
\"created_at\": \"2023-06-14T16:56:30Z\",
\"assets\": [
{
\"url\": \"http://127.0.0.1:12346/fake.msixbundle\",
\"id\": 1,
\"name\": \"Microsoft.WSL_1.0.0.0_x64_ARM64.msixbundle\"
}
]
}])";
Comment on lines +627 to 640
typedef enum WslcInstallOptions
{
WSLC_INSTALL_OPTION_NONE = 0,
// Allows components to be reinstalled.
WSLC_INSTALL_OPTION_REPAIR = 1,
} WslcInstallOptions;

DEFINE_ENUM_FLAG_OPERATORS(WslcInstallOptions);

// Callbacks will only be made for components that are actively installed by this call.
// That list can be acquired prior to this call with `WslcCanRun`.
STDAPI WslcInstallWithDependencies(_In_opt_ WslcInstallCallback progressCallback, _In_opt_ PVOID context);
// The list of required components can be acquired prior to this call with `WslcGetMissingComponents`.
STDAPI WslcInstallWithDependencies(
_In_ WslcComponentFlags components, _In_ WslcInstallOptions options, _In_opt_ WslcInstallCallback progressCallback, _In_opt_ PVOID context);

Comment on lines 267 to 273
runtimeclass WslcService
{
static IVectorView<Component> GetMissingComponents();
static ServiceVersion GetVersion();
static void InstallWithDependencies();
static Windows.Foundation.IAsyncActionWithProgress<InstallProgress> InstallWithDependenciesAsync();
static void InstallWithDependencies(InstallOptions options);
static Windows.Foundation.IAsyncActionWithProgress<InstallProgress> InstallWithDependenciesAsync(InstallOptions options);
};
Comment on lines +1671 to 1674
// This API cannot update the SDK that the client is using.
RETURN_HR_IF(WSLC_E_SDK_UPDATE_NEEDED, WI_IsFlagSet(components, WSLC_COMPONENT_FLAG_SDK_NEEDS_UPDATE));

HRESULT result = S_OK;
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.

2 participants