[Setup] Use custom prefix for WiX bootstrapper logs and collect them via BugReportTool (#17062)

This commit is contained in:
Andrey Nekrasov 2022-03-16 14:39:00 +03:00 committed by GitHub
parent 79d4782b23
commit 41f4d971dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 5 deletions

View File

@ -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. -->

View File

@ -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());
}
@ -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))
{
@ -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)
@ -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
@ -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");
}
@ -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);