From af10fa6c584d139b491d531bef3e90ec4275f69c Mon Sep 17 00:00:00 2001 From: John McPherson Date: Tue, 13 Jan 2026 11:30:02 -0800 Subject: [PATCH 1/5] More data to diagnose pipeline failures --- azure-pipelines.yml | 13 + .../ShutdownMonitoring.cpp | 9 - .../AppInstallerTelemetry.cpp | 2 +- src/WinGetServer/WinMain.cpp | 7 +- src/WindowsPackageManager/Source.def | 1 + .../WindowsPackageManager.h | 3 + src/WindowsPackageManager/main.cpp | 7 + tools/HAMTrace/WER.HostActivityManager.wprp | 261 ++++++++++++++++++ 8 files changed, 292 insertions(+), 11 deletions(-) create mode 100644 tools/HAMTrace/WER.HostActivityManager.wprp diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c62c5dc734..1a86b888a7 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -331,6 +331,13 @@ jobs: inputs: packageFeedSelector: 'nugetOrg' + # Temporarily enable this tracing collection until the issue with the following Install is fixed. Then move to debug only as the COM tracing in the e2e-test.template does. + - task: CmdLine@2 + displayName: Start HAM trace + condition: succeededOrFailed() + 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 @@ -339,6 +346,12 @@ jobs: displayName: Install Sysinternals PsTools Using Winget condition: succeededOrFailed() + - task: CmdLine@2 + displayName: Complete HAM trace + condition: succeededOrFailed() + 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..e6af9a2fad 100644 --- a/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp +++ b/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp @@ -251,7 +251,7 @@ namespace AppInstaller::Logging } } - AICLI_LOG(Core, Info, << "WinGet, version [" << version << "], activity [" << *GetActivityId() << ']'); + AICLI_LOG(Core, Info, << "WinGet, version [" << version << "], PID [" << GetCurrentProcessId() << "], activity [" << *GetActivityId() << ']'); 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..0a37420ff6 --- /dev/null +++ b/tools/HAMTrace/WER.HostActivityManager.wprp @@ -0,0 +1,261 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 861fb19a3a13f25429d96dcd71676e8301266912 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Wed, 14 Jan 2026 10:12:18 -0800 Subject: [PATCH 2/5] Spelling and additional provider --- .github/actions/spelling/excludes.txt | 1 + tools/HAMTrace/WER.HostActivityManager.wprp | 1 + 2 files changed, 2 insertions(+) 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/tools/HAMTrace/WER.HostActivityManager.wprp b/tools/HAMTrace/WER.HostActivityManager.wprp index 0a37420ff6..83c5fdc8b3 100644 --- a/tools/HAMTrace/WER.HostActivityManager.wprp +++ b/tools/HAMTrace/WER.HostActivityManager.wprp @@ -189,6 +189,7 @@ + From a36bd3c34949ef8938053487559683ffa5cb2e7c Mon Sep 17 00:00:00 2001 From: John McPherson Date: Wed, 14 Jan 2026 14:11:30 -0800 Subject: [PATCH 3/5] Update process info logging, update event provider --- src/AppInstallerCommonCore/AppInstallerTelemetry.cpp | 4 +++- tools/HAMTrace/WER.HostActivityManager.wprp | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp b/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp index e6af9a2fad..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_) @@ -251,7 +252,8 @@ namespace AppInstaller::Logging } } - AICLI_LOG(Core, Info, << "WinGet, version [" << version << "], PID [" << GetCurrentProcessId() << "], activity [" << *GetActivityId() << ']'); + 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/tools/HAMTrace/WER.HostActivityManager.wprp b/tools/HAMTrace/WER.HostActivityManager.wprp index 83c5fdc8b3..57c000f14e 100644 --- a/tools/HAMTrace/WER.HostActivityManager.wprp +++ b/tools/HAMTrace/WER.HostActivityManager.wprp @@ -189,7 +189,11 @@ - + + + + + @@ -249,6 +253,8 @@ + + From 9c32dae6bc14ecb476a900dac504df67dbcca7e1 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Wed, 14 Jan 2026 17:09:27 -0800 Subject: [PATCH 4/5] Remove AllUsers --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1a86b888a7..55a3045442 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -341,7 +341,7 @@ jobs: - 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() From 4086e4b1c614dfd7d1355abf9bed476e44459da3 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Thu, 15 Jan 2026 08:45:37 -0800 Subject: [PATCH 5/5] Make trace conditional on debug --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 55a3045442..c7e5af1fcf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -331,10 +331,9 @@ jobs: inputs: packageFeedSelector: 'nugetOrg' - # Temporarily enable this tracing collection until the issue with the following Install is fixed. Then move to debug only as the COM tracing in the e2e-test.template does. - task: CmdLine@2 displayName: Start HAM trace - condition: succeededOrFailed() + condition: and(succeededOrFailed(), eq(variables['System.debug'], true)) inputs: script: 'wpr -start $(Build.SourcesDirectory)\tools\HAMTrace\WER.HostActivityManager.wprp -filemode' @@ -348,7 +347,7 @@ jobs: - task: CmdLine@2 displayName: Complete HAM trace - condition: succeededOrFailed() + condition: and(succeededOrFailed(), eq(variables['System.debug'], true)) inputs: script: 'wpr -stop "$(artifactsDir)\HamTrace.etl"'