Repository: microsoft/terminal (language: cpp)

Issue:
PGO has been "at a farm upstate" since VS 2022
<img width="1049" alt="image" src="https://user-images.githubusercontent.com/189190/178838290-8754633e-bbf6-400d-9371-533a9416f0e3.png">

There are only five commits in that range, and not one of them might explain what is happening better than the VS 2022 one.


Discussion / hints:
Fortunately Helix gives us dumps

and this one looks like "I couldn't load TerminalApp.dll, yo"

```
0b 00000018`9ff5f450 00007ff6`bff0e91d     WindowsTerminal!winrt::throw_hresult+0x3ba [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\base.h @ 4946] 
0c 00000018`9ff5f4b0 00007ff6`bff0ebbe     WindowsTerminal!winrt::check_hresult+0x2d [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\base.h @ 5016] 
0d 00000018`9ff5f4f0 00007ff6`bff30f9e     WindowsTerminal!winrt::get_activation_factory<winrt::Windows::Foundation::IActivationFactory>+0x7e [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\base.h @ 6039] 
0e 00000018`9ff5f550 00007ff6`bff232fb     WindowsTerminal!winrt::impl::factory_cache_entry<winrt::TerminalApp::App,winrt::Windows::Foundation::IActivationFactory>::call<winrt::TerminalApp::App (__cdecl*)(winrt::Windows::Foundation::IActivationFactory const &)>+0x9e [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\base.h @ 6266] 
0f 00000018`9ff5f600 00007ff6`bff24aa9     WindowsTerminal!winrt::impl::call_factory_cast<winrt::TerminalApp::App (__cdecl*)(winrt::Windows::Foundation::IActivationFactory const &),winrt::TerminalApp::App,winrt::Windows::Foundation::IActivationFactory,`winrt::TerminalApp::App::App'::`1'::<lambda_164_> >+0xab [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\base.h @ 6325] 
10 00000018`9ff5f640 00007ff6`bff34f73     WindowsTerminal!winrt::TerminalApp::App::App+0x39 [C:\a\_work\1\s\src\cascadia\WindowsTerminal\Generated Files\winrt\TerminalApp.h @ 6090] 
11 00000018`9ff5f680 00007ff6`bff2e913     WindowsTerminal!AppHost::AppHost+0x63 [C:\a\_work\1\s\src\cascadia\WindowsTerminal\AppHost.cpp @ 32] 
12 00000018`9ff5f760 00007ff6`bff27fe2     WindowsTerminal!wWinMain+0x183 [C:\a\_work\1\s\src\cascadia\WindowsTerminal\main.cpp @ 139] 
```
It loads properly on Windows 11 SV2...

Time to unearth the Vb VM
It... doesn't fail on the VB VM. Oh man.
I'm guessing that the Helix machines have an old version of the VC++ redist that is missing `msvcp140_atomic_wait.dll`

Fix patch:
diff --git a/build/Helix/PrepareHelixPayload.ps1 b/build/Helix/PrepareHelixPayload.ps1
index 99e840f8b07..3f9600492e7 100644
--- a/build/Helix/PrepareHelixPayload.ps1
+++ b/build/Helix/PrepareHelixPayload.ps1
@@ -55,8 +55,9 @@ Copy-Item "build\helix\runtests.cmd" $payloadDir
 Copy-Item "build\helix\InstallTestAppDependencies.ps1" "$payloadDir"
 Copy-Item "build\Helix\EnsureMachineState.ps1" "$payloadDir"
 
-# Copy the APPX package from the 'drop' artifact dir
+# Copy the APPX package from the 'drop' artifact dir and Windows Kits
 Copy-Item "$repoDirectory\Artifacts\$ArtifactName\appx\CascadiaPackage_0.0.1.0_$Platform.msix" $payloadDir\CascadiaPackage.zip
+Copy-Item "C:\program files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Retail\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx" $payloadDir\VCLibs.zip
 
 # Rename it to extension of ZIP because Expand-Archive is real sassy on the build machines
 # and refuses to unzip it because of its file extension while on a desktop, it just
@@ -64,3 +65,4 @@ Copy-Item "$repoDirectory\Artifacts\$ArtifactName\appx\CascadiaPackage_0.0.1.0_$
 
 # Extract the APPX package
 Expand-Archive -LiteralPath $payloadDir\CascadiaPackage.zip -DestinationPath $payloadDir\appx
+Expand-Archive -LiteralPath $payloadDir\VCLibs.zip -DestinationPath $payloadDir\appx -Force


Test patch: