diagnostics: collect MSI verbose install logs in diagnostic bundle#40218
Conversation
There was a problem hiding this comment.
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. |
23c5e61 to
9f6cebe
Compare
9f6cebe to
ab514ad
Compare
ab514ad to
4b6b1b9
Compare
4b6b1b9 to
504b678
Compare
There was a problem hiding this comment.
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_logcleanup 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()));
}
504b678 to
e4525ce
Compare
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>
e4525ce to
db35b1f
Compare
There was a problem hiding this comment.
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);
- 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>
- 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>
|
Addressed all review feedback in latest push:
|
There was a problem hiding this comment.
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.txtpath 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 {};
Summary
Collect the MSI verbose install log in the diagnostic bundle so MSI-level failures can be diagnosed from user-uploaded logs.
Before
wsl --updatewrites MSI log to%TEMP%\wsl-install-logs.txt(delete on success, keep on failure)WslInstaller) wrote no MSI log when registryUpgradeLogFilewas empty (the default)After
WslInstaller.cppnow defaults to%TEMP%\wsl-install-logs.txt(same path aswsl --update), with delete-on-success / preserve-on-failureAll MSI upgrade paths now write to one location:
wsl --update%TEMP%\wsl-install-logs.txt%TEMP%\wsl-install-logs.txtTested
Installed MSI with active file lock contention on
WSL.lnk. Collected log contains:PR Checklist
Changes
src/windows/wslinstaller/exe/WslInstaller.cppdiagnostics/collect-wsl-logs.ps1%TEMP%\wsl-install-logs.txt