Skip to content

Commit ff1ae97

Browse files
Update build.yml to test including process dumps
Needed to help diagnose issue CommunityToolkit/Windows#347
1 parent 027946a commit ff1ae97

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

.github/workflows/build.yml

+46-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717

1818
env:
1919
DOTNET_VERSION: ${{ '8.0.x' }}
20-
ENABLE_DIAGNOSTICS: false
20+
ENABLE_DIAGNOSTICS: true
2121
#COREHOST_TRACE: 1
2222
COREHOST_TRACEFILE: corehosttrace.log
2323

@@ -153,6 +153,44 @@ jobs:
153153
minimum-size: 32GB
154154
maximum-size: 32GB
155155
disk-root: "C:"
156+
157+
- name: Enable Crash Dumps
158+
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
159+
shell: pwsh
160+
run: |
161+
# If we set the registry from a 32-bit process on a 64-bit machine, we will set the "virtualized" syswow registry.
162+
# For crash dump collection we always want to set the "native" registry, so we make sure to invoke the native cmd.exe
163+
$nativeCmdPath = "$env:SystemRoot\system32\cmd.exe"
164+
if([Environment]::Is64BitOperatingSystem -and ![Environment]::Is64BitProcess)
165+
{
166+
# The "sysnative" path is a 'magic' path that allows a 32-bit process to invoke the native 64-bit cmd.exe.
167+
$nativeCmdPath = "$env:SystemRoot\sysnative\cmd.exe"
168+
}
169+
170+
if(!$dumpFolder)
171+
{
172+
$dumpFolder = "C:\dumps"
173+
}
174+
175+
function Enable-CrashDumpsForProcesses {
176+
Param([string[]]$namesOfProcessesForDumpCollection)
177+
178+
foreach($procName in $namesOfProcessesForDumpCollection )
179+
{
180+
Write-Host "Enabling local crash dumps for $procName"
181+
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpFolder /t REG_EXPAND_SZ /d $dumpFolder /f
182+
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpType /t REG_DWORD /d 2 /f
183+
& $nativeCmdPath /c reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\$procName" /v DumpCount /t REG_DWORD /d 3 /f
184+
}
185+
}
186+
187+
# enable dump collection for our test apps:
188+
$namesOfProcessesForDumpCollection = @(
189+
"CommunityToolkit.Tests.Uwp.exe",
190+
"CommunityToolkit.Tests.WinAppSdk.exe",
191+
"VSTest.Console.exe")
192+
193+
Enable-CrashDumpsForProcesses $namesOfProcessesForDumpCollection
156194
157195
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
158196
uses: actions/setup-dotnet@v4
@@ -235,6 +273,13 @@ jobs:
235273
name: new-experiment-logs
236274
path: ./**/*.*log
237275

276+
- name: Artifact - Process Dumps
277+
uses: actions/upload-artifact@v4
278+
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
279+
with:
280+
name: new-experiment-dumps
281+
path: C:/dumps/*.*dmp
282+
238283
wasm-linux:
239284
runs-on: ubuntu-latest
240285
env:

0 commit comments

Comments
 (0)