diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 33b8921fa2..5ad5826bde 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -88,6 +88,7 @@ \.webm$ \.webp$ \.woff2?$ +\.wprp$ \.xcf$ \.xlsx?$ \.xpm$ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c62c5dc734..c7e5af1fcf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -331,14 +331,26 @@ jobs: inputs: packageFeedSelector: 'nugetOrg' + - task: CmdLine@2 + displayName: Start HAM trace + condition: and(succeededOrFailed(), eq(variables['System.debug'], true)) + inputs: + script: 'wpr -start $(Build.SourcesDirectory)\tools\HAMTrace\WER.HostActivityManager.wprp -filemode' + - powershell: | Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module Microsoft.WinGet.Client -Repository PSGallery -Force - try { Repair-WingetPackageManager -AllUsers -Latest -Verbose } catch { $_.Exception } + try { Repair-WingetPackageManager -Latest -Verbose } catch { $_.Exception } Install-WinGetPackage -Id Microsoft.Sysinternals.PsTools -Source winget displayName: Install Sysinternals PsTools Using Winget condition: succeededOrFailed() + - task: CmdLine@2 + displayName: Complete HAM trace + condition: and(succeededOrFailed(), eq(variables['System.debug'], true)) + inputs: + script: 'wpr -stop "$(artifactsDir)\HamTrace.etl"' + - pwsh: | $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") PsExec -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -mdmpto $(artifactsDir)\AICLI-Unpackaged-System.mdmp -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml diff --git a/src/AppInstallerCLICore/ShutdownMonitoring.cpp b/src/AppInstallerCLICore/ShutdownMonitoring.cpp index 3450e13eb9..f04d3a821c 100644 --- a/src/AppInstallerCLICore/ShutdownMonitoring.cpp +++ b/src/AppInstallerCLICore/ShutdownMonitoring.cpp @@ -352,15 +352,6 @@ namespace AppInstaller::ShutdownMonitoring void ServerShutdownSynchronization::Signal(CancelReason reason) { - { - // Check for registered components before creating a thread to do nothing - std::lock_guard lock{ m_componentsLock }; - if (m_components.empty()) - { - return; - } - } - std::lock_guard lock{ m_threadLock }; if (!m_shutdownThread.joinable()) diff --git a/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp b/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp index bfefd72d9e..9155a642c1 100644 --- a/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp +++ b/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp @@ -7,6 +7,7 @@ #include "Public/AppInstallerSHA256.h" #include "Public/AppInstallerStrings.h" #include "Public/winget/ThreadGlobals.h" +#include "winget/Filesystem.h" #include "winget/UserSettings.h" #define AICLI_TraceLoggingStringView(_sv_,_name_) TraceLoggingCountedUtf8String(_sv_.data(), static_cast(_sv_.size()), _name_) @@ -252,6 +253,7 @@ namespace AppInstaller::Logging } AICLI_LOG(Core, Info, << "WinGet, version [" << version << "], activity [" << *GetActivityId() << ']'); + AICLI_LOG(Core, Info, << "Process: " << Filesystem::GetExecutablePathForProcess(GetCurrentProcess()).filename() << "[" << GetCurrentProcessId() << "], Offset: " << &__ImageBase); AICLI_LOG(Core, Info, << "OS: " << Runtime::GetOSVersion()); AICLI_LOG(Core, Info, << "Command line Args: " << Utility::ConvertToUTF8(GetCommandLineW())); if (Runtime::IsRunningInPackagedContext()) diff --git a/src/WinGetServer/WinMain.cpp b/src/WinGetServer/WinMain.cpp index 43378f1fc6..b39f379483 100644 --- a/src/WinGetServer/WinMain.cpp +++ b/src/WinGetServer/WinMain.cpp @@ -217,6 +217,7 @@ int __stdcall wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPWSTR cmdLine, } _comServerExitEvent.wait(); + WindowsPackageManagerServerLog("Server shutting down after exit event signaled."); if (manualResetEvent) { @@ -228,7 +229,11 @@ int __stdcall wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPWSTR cmdLine, RETURN_IF_FAILED(WindowsPackageManagerServerModuleUnregister()); } } - CATCH_RETURN() + catch (...) + { + LOG_CAUGHT_EXCEPTION(); + RETURN_CAUGHT_EXCEPTION(); + } return 0; } diff --git a/src/WindowsPackageManager/Source.def b/src/WindowsPackageManager/Source.def index 419e7ad3f6..887d711dd2 100644 --- a/src/WindowsPackageManager/Source.def +++ b/src/WindowsPackageManager/Source.def @@ -12,3 +12,4 @@ EXPORTS WindowsPackageManagerInProcModuleGetClassObject WindowsPackageManagerInProcModuleGetActivationFactory WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization + WindowsPackageManagerServerLog diff --git a/src/WindowsPackageManager/WindowsPackageManager.h b/src/WindowsPackageManager/WindowsPackageManager.h index 1842e27b8c..37241403a8 100644 --- a/src/WindowsPackageManager/WindowsPackageManager.h +++ b/src/WindowsPackageManager/WindowsPackageManager.h @@ -48,4 +48,7 @@ extern "C" // DllGetActivationFactory for in-proc cpp winrt runtime classes. WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleGetActivationFactory(HSTRING classId, void** factory); + + // Allows logging from callers. + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerLog(const char* message); } diff --git a/src/WindowsPackageManager/main.cpp b/src/WindowsPackageManager/main.cpp index 96d82c08b8..4ccb238d76 100644 --- a/src/WindowsPackageManager/main.cpp +++ b/src/WindowsPackageManager/main.cpp @@ -141,4 +141,11 @@ extern "C" return WINRT_GetActivationFactory(classId, factory); } CATCH_RETURN(); + + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerLog(const char* message) try + { + AppInstaller::Logging::Log().Write(AppInstaller::Logging::Channel::Core, AppInstaller::Logging::Level::Info, message); + return S_OK; + } + CATCH_RETURN(); } diff --git a/tools/HAMTrace/WER.HostActivityManager.wprp b/tools/HAMTrace/WER.HostActivityManager.wprp new file mode 100644 index 0000000000..57c000f14e --- /dev/null +++ b/tools/HAMTrace/WER.HostActivityManager.wprp @@ -0,0 +1,268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +