Skip to content

Commit

Permalink
[Setup] Use custom prefix for WiX bootstrapper logs and collect them …
Browse files Browse the repository at this point in the history
…via BugReportTool (#17062)
  • Loading branch information
yuyoyuppe authored Mar 16, 2022
1 parent 79d4782 commit 41f4d97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions installer/PowerToysSetup/PowerToys.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

<Variable Name="InstallFolder" Type="string" Value="[ProgramFiles64Folder]PowerToys" bal:Overridable="yes"/>

<Variable Name="MsiLogFolder" Type="string" Value="[LocalAppDataFolder]\Microsoft\PowerToys\" />
<Log Disable="no" Prefix='powertoys-bootstrapper-msi-$(var.Version)' Extension=".log" />

<!-- Only install/upgrade if the version is greater or equal than the currently installed version of PowerToys, to handle the case in which PowerToys was installed from old MSI (before WiX bootstrapper was used) -->
<!-- If the previous installation is a bundle installation, just let WiX run its logic. -->
Expand Down
32 changes: 27 additions & 5 deletions tools/BugReportTool/BugReportTool/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void ReportWindowsVersion(const filesystem::path& tmpDir)
versionReport << "MinorVersion: " << osInfo.dwMinorVersion << endl;
versionReport << "BuildNumber: " << osInfo.dwBuildNumber << endl;
}
catch(...)
catch (...)
{
printf("Failed to write to %s\n", versionReportPath.string().c_str());
}
Expand All @@ -197,7 +197,7 @@ void ReportWindowsSettings(const filesystem::path& tmpDir)
try
{
const auto lang = winrt::Windows::System::UserProfile::GlobalizationPreferences::Languages().GetAt(0);
userLanguage = winrt::Windows::Globalization::Language{lang}.DisplayName().c_str();
userLanguage = winrt::Windows::Globalization::Language{ lang }.DisplayName().c_str();
wchar_t localeName[LOCALE_NAME_MAX_LENGTH]{};
if (!LCIDToLocaleName(GetThreadLocale(), localeName, LOCALE_NAME_MAX_LENGTH, 0))
{
Expand All @@ -217,11 +217,10 @@ void ReportWindowsSettings(const filesystem::path& tmpDir)
settingsReport << "Preferred user language: " << userLanguage << endl;
settingsReport << "User locale: " << userLocale << endl;
}
catch(...)
catch (...)
{
printf("Failed to write windows settings\n");
}

}

void ReportDotNetInstallationInfo(const filesystem::path& tmpDir)
Expand Down Expand Up @@ -253,6 +252,27 @@ void ReportVCMLogs(const filesystem::path& tmpDir, const filesystem::path& repor
copy(tmpDir / "PowerToysVideoConference_x64.log", reportDir, ec);
}

void ReportInstallerLogs(const filesystem::path& tmpDir, const filesystem::path& reportDir)
{
const char* logFilePrefix = "powertoys-bootstrapper-msi-";

for (auto& entry : directory_iterator{ tmpDir })
{
std::error_code ec;
if (entry.is_directory(ec) || !entry.path().has_filename())
{
continue;
}

const auto fileName = entry.path().filename().string();
if (!fileName.starts_with(logFilePrefix))
{
continue;
}
copy(entry.path(), reportDir / fileName, ec);
}
}

int wmain(int argc, wchar_t* argv[], wchar_t*)
{
// Get path to save zip
Expand Down Expand Up @@ -289,7 +309,7 @@ int wmain(int argc, wchar_t* argv[], wchar_t*)
try
{
copy(settingsRootPath, reportDir, copy_options::recursive);

// Remove updates folder contents
DeleteFolder(reportDir / "Updates");
}
Expand Down Expand Up @@ -328,6 +348,8 @@ int wmain(int argc, wchar_t* argv[], wchar_t*)
EventViewer::ReportEventViewerInfo(reportDir);

ReportVCMLogs(tempDir, reportDir);

ReportInstallerLogs(tempDir, reportDir);

// Zip folder
auto zipPath = path::path(saveZipPath);
Expand Down

0 comments on commit 41f4d97

Please sign in to comment.