Skip to content

diagnostics: collect MSI verbose install logs in diagnostic bundle#40218

Merged
yeelam-gordon merged 3 commits into
masterfrom
fix/collect-msi-install-log
Apr 24, 2026
Merged

diagnostics: collect MSI verbose install logs in diagnostic bundle#40218
yeelam-gordon merged 3 commits into
masterfrom
fix/collect-msi-install-log

Conversation

@yeelam-gordon

@yeelam-gordon yeelam-gordon commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Collect the MSI verbose install log in the diagnostic bundle so MSI-level failures can be diagnosed from user-uploaded logs.

Before

  • wsl --update writes MSI log to %TEMP%\wsl-install-logs.txt (delete on success, keep on failure)
  • Store/winget upgrade path (WslInstaller) wrote no MSI log when registry UpgradeLogFile was empty (the default)
  • Diagnostic collector did not collect the MSI log
BEFORE collector output:
  wsl-install-log.txt   (5 KB)    <- high-level WSL log only, no MSI detail

After

  • WslInstaller.cpp now defaults to %TEMP%\wsl-install-logs.txt (same path as wsl --update), with delete-on-success / preserve-on-failure
  • Collector picks up the MSI log

All MSI upgrade paths now write to one location:

Path Log Cleanup
wsl --update %TEMP%\wsl-install-logs.txt Already did (unchanged)
Store/winget %TEMP%\wsl-install-logs.txt NEW (was: no log)
Both Same file Delete on success, preserve on failure
AFTER collector output (on failure):
  wsl-install-log.txt     (5 KB)
  wsl-install-logs.txt  (265 KB)  <- MSI verbose log with failure detail

Tested

Installed MSI with active file lock contention on WSL.lnk. Collected log contains:

Warning 1946.Property 'System.AppUserModel.ID' for shortcut 'WSL.lnk' could not be set. HRESULT 32.
Warning 1946.Property 'System.AppUserModel.ToastActivatorCLSID' for shortcut 'WSL.lnk' could not be set. HRESULT 32.

PR Checklist

Changes

File Change
src/windows/wslinstaller/exe/WslInstaller.cpp Default log path + delete-on-success / preserve-on-failure
diagnostics/collect-wsl-logs.ps1 Collect %TEMP%\wsl-install-logs.txt
Copilot AI review requested due to automatic review settings April 17, 2026 08:55
@yeelam-gordon yeelam-gordon requested a review from a team as a code owner April 17, 2026 08:55

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

Adds MSI verbose installer log retention and collection to WSL’s diagnostic bundle (collect-wsl-logs.ps1) so MSI-level install/upgrade failures can be diagnosed from user-provided logs.

Changes:

  • Stop auto-deleting the MSI verbose install log after a successful MSI-based update.
  • Extend diagnostic bundle collection to include the MSI verbose log from %TEMP%.
  • Also attempt to collect an MSI upgrade log whose path is specified via HKLM\...\Lxss\MSI\UpgradeLogFile.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/windows/common/install.cpp Keeps the MSI verbose log (wsl-install-logs.txt) instead of deleting it on success, enabling post-install diagnostics.
diagnostics/collect-wsl-logs.ps1 Copies MSI verbose install logs into the diagnostic folder, including a registry-specified upgrade log location.
Comment thread src/windows/common/install.cpp
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from 23c5e61 to 9f6cebe Compare April 17, 2026 09:05
Copilot AI review requested due to automatic review settings April 17, 2026 09:16
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from 9f6cebe to ab514ad Compare April 17, 2026 09:16

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
Comment thread msipackage/package.wix.in Outdated
Comment thread msipackage/package.wix.in Outdated
Comment thread msipackage/package.wix.in Outdated
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from ab514ad to 4b6b1b9 Compare April 17, 2026 09:22
Copilot AI review requested due to automatic review settings April 17, 2026 09:27
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from 4b6b1b9 to 504b678 Compare April 17, 2026 09:27

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/windows/common/install.cpp:111

  • The MSI verbose log file (wsl-install-logs.txt) is no longer deleted on successful updates because the wil::scope_exit_log cleanup was removed. This leaves the verbose MSI log behind in the user temp directory even when the update succeeds, which contradicts the intent described in the PR ("preserved on failed wsl --update") and can leave stale/possibly sensitive installer logs on disk. Consider restoring scoped cleanup and only keeping the file when the MSI exit code is non-zero (or when warnings/errors were observed during the install), so success cases don’t persist the log indefinitely.
        auto logFile = std::filesystem::temp_directory_path() / L"wsl-install-logs.txt";

        const auto exitCode = UpgradeViaMsi(downloadPath.c_str(), L"", logFile.c_str(), &MsiMessageCallback);

        if (exitCode != 0)
        {
            THROW_HR_WITH_USER_ERROR(
                HRESULT_FROM_WIN32(exitCode),
                wsl::shared::Localization::MessageUpdateFailed(exitCode) + L"\r\n" +
                    wsl::shared::Localization::MessageSeeLogFile(logFile.c_str()));
        }
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from 504b678 to e4525ce Compare April 17, 2026 09:36
The MSI verbose log (wsl-install-logs.txt) is generated during MSI
upgrades via MsiEnableLog but was not collected by the diagnostic
script. Additionally, the Store/winget upgrade path (WslInstaller)
did not write an MSI log at all when no registry override was set.

Changes:
- WslInstaller.cpp: default to %TEMP%\wsl-install-logs.txt when
  UpgradeLogFile registry key is empty, with delete-on-success /
  preserve-on-failure (same pattern as wsl --update in install.cpp)
- collect-wsl-logs.ps1: collect %TEMP%\wsl-install-logs.txt

Now all MSI upgrade paths write to the same log location:
- wsl --update: already writes here (install.cpp)
- Store/winget: now also writes here (WslInstaller.cpp)
- Both: delete on success, preserve on failure

Tested: installed MSI with file lock contention, collected log
contains Warning 1946 detail for diagnosis.

Refs: #13469, #11276, #12759

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 09:37
@yeelam-gordon yeelam-gordon force-pushed the fix/collect-msi-install-log branch from e4525ce to db35b1f Compare April 17, 2026 09:37

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/windows/wslinstaller/exe/WslInstaller.cpp:47

  • GetUpgradeLogFileLocation() returns a std::wstring, but this branch returns a std::filesystem::path via implicit conversion (weakly_canonical(path)). Please make the conversion explicit (e.g., call .wstring()), matching GetMsiPackagePath() and avoiding reliance on implicit path->string conversions.
    // A canonical path is required because msiexec doesn't like symlinks.
    return std::filesystem::weakly_canonical(path);
Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp Outdated
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp Outdated

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp Outdated
- Treat ERROR_SUCCESS_REBOOT_REQUIRED (3010) as success when deciding
  whether to preserve MSI logs (delete-on-success, keep-on-failure).
- Collect logs from both user temp and system temp (WslInstaller service
  runs as SYSTEM, so its temp_directory_path resolves to %WINDIR%\Temp).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
Comment thread diagnostics/collect-wsl-logs.ps1 Outdated
Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp
- Add UpgradeLogInfo struct with fromRegistry flag to skip log deletion
  when the UpgradeLogFile registry value is explicitly set (per OneBlue)
- Remove duplicate system temp copy in collector (per OneBlue)
- Fix forward-slash inconsistency in collector (per ptrivedi)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 11:03
@yeelam-gordon

Copy link
Copy Markdown
Contributor Author

Addressed all review feedback in latest push:

  • @ptrivedi (slash nit): Fixed to backslash for consistency ✓
  • @OneBlue (duplicate copy): Removed the system temp copy line — single \C:\Users\yeelam\AppData\Local\Temp\wsl-install-logs.txt\ collection ✓
  • @OneBlue (override): Resolved by removing the duplicate line ✓
  • @OneBlue (UpgradeLogFile registry): Added \UpgradeLogInfo\ struct with \ romRegistry\ flag — when the registry key is explicitly set, the log is always preserved (never deleted on success) ✓

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/windows/wslinstaller/exe/WslInstaller.cpp:58

  • GetUpgradeLogFileLocation() returns {} on any exception (registry read failure, missing key, temp path failure), which disables MSI logging entirely. Since this PR’s goal is to always have an MSI log available for diagnostics, consider falling back to the default %TEMP%\wsl-install-logs.txt path even in the catch path (and/or when the Lxss key can’t be opened), rather than returning no log file.
catch (...)
{
    LOG_CAUGHT_EXCEPTION();
    return {};
Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp
@yeelam-gordon yeelam-gordon merged commit 2c42f23 into master Apr 24, 2026
13 checks passed
@yeelam-gordon yeelam-gordon deleted the fix/collect-msi-install-log branch April 24, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants