Repository navigation
Adding log files for capturing Windows ML logs - #602
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Samples/WindowsML/capture-logs diagnostics drop (profiles + helper script) and links it from the Windows ML sample docs so developers can capture Windows ML/ONNX diagnostic traces and generate a summarized rundown log.
Changes:
- Adds a WPR profile (
WinML.wprp) for capturing Windows ML + ONNX/ORT provider events. - Adds a PowerShell helper (
Get-WinMLRundown.ps1) to export ETL data via WPA exporter and generate a consolidated log. - Updates repo documentation to surface the new “Capture Logs” resource under Windows ML.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Samples/WindowsML/capture-logs/WinML.wprp | New WPR profile defining providers/collectors for WinML/ONNX/ORT diagnostics. |
| Samples/WindowsML/capture-logs/README.md | Documents the capture-logs artifacts and points to Microsoft Learn instructions. |
| Samples/WindowsML/capture-logs/Get-WinMLRundown.ps1 | Exports ETL → CSV and merges/renames fields into a single rundown log. |
| Samples/WindowsML/README.md | Adds a “Diagnostics” section linking to capture-logs. |
| README.md | Adds a top-level link to the Windows ML capture-logs resource. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Write-Host " Destination: $installerPath" | ||
|
|
||
| try { | ||
| Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing |
There was a problem hiding this comment.
Invoke-WebRequest -UseBasicParsing is not supported in PowerShell 6+/7+ (the parameter was removed), which will cause this script to fail when run under modern PowerShell. If you need compatibility with both Windows PowerShell 5.1 and PowerShell 7, gate the parameter based on availability or avoid it entirely.
| Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing | |
| if ($PSVersionTable.PSVersion.Major -lt 6) { | |
| Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing | |
| } else { | |
| Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath | |
| } |
| # Step 2: Get all CSV files | ||
| $csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv | ||
|
|
||
| if ($csvFiles.Count -eq 0) { | ||
| Set-Content -Path $LogFilePath -Value "No CSV files found." | ||
| exit |
There was a problem hiding this comment.
The script invokes wpaexporter.exe but doesn’t check whether it succeeded (e.g., via $LASTEXITCODE) before continuing. If export fails, the script falls through to “No CSV files found.” and exits, which can mask the underlying failure; consider checking the exit code and writing a clearer error + returning a non-zero exit code.
| # Step 2: Get all CSV files | |
| $csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv | |
| if ($csvFiles.Count -eq 0) { | |
| Set-Content -Path $LogFilePath -Value "No CSV files found." | |
| exit | |
| if ($LASTEXITCODE -ne 0) { | |
| $errorMessage = "wpaexporter.exe failed with exit code $LASTEXITCODE." | |
| Write-Host $errorMessage | |
| if ($LogFilePath) { | |
| Set-Content -Path $LogFilePath -Value $errorMessage | |
| } | |
| exit $LASTEXITCODE | |
| } | |
| # Step 2: Get all CSV files | |
| $csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv | |
| if ($csvFiles.Count -eq 0) { | |
| Set-Content -Path $LogFilePath -Value "No CSV files found after export." | |
| exit 1 |
| exit | ||
| } | ||
|
|
||
| if (-not ($allData | Get-Member -Name "Process")) { | ||
| Set-Content -Path $LogFilePath -Value "No 'Process' column found." | ||
| exit |
There was a problem hiding this comment.
Several error paths call exit without an explicit non-zero status (e.g., when no CSV files/data/Process column are found). This can cause CI/scripts to treat failures as success. Use a non-zero exit code for these failure cases (or throw) so callers can reliably detect failure.
| exit | |
| } | |
| if (-not ($allData | Get-Member -Name "Process")) { | |
| Set-Content -Path $LogFilePath -Value "No 'Process' column found." | |
| exit | |
| exit 1 | |
| } | |
| if (-not ($allData | Get-Member -Name "Process")) { | |
| Set-Content -Path $LogFilePath -Value "No 'Process' column found." | |
| exit 1 |
| $installerPath = "$env:TEMP\adksetup.exe" | ||
|
|
||
| Write-Host "Downloading Windows ADK installer..." | ||
| Write-Host " URL: $adkUrl" | ||
| Write-Host " Destination: $installerPath" | ||
|
|
||
| try { | ||
| Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing | ||
| Write-Host " [OK] Download complete" -ForegroundColor Green | ||
| } catch { | ||
| Write-Host "Failed to download Windows ADK installer: $_" -ForegroundColor Red | ||
| throw | ||
| } | ||
|
|
||
| Write-Host "Installing Windows Performance Toolkit feature..." | ||
| Write-Host " This may take a few minutes..." | ||
|
|
||
| $installArgs = "/quiet /norestart /features OptionId.WindowsPerformanceToolkit" | ||
| Write-Host " Running: $installerPath $installArgs" | ||
|
|
||
| $process = Start-Process -FilePath $installerPath -ArgumentList $installArgs -Wait -PassThru | ||
|
|
||
| if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 3010) { | ||
| Write-Host " [OK] Installation complete (Exit code: $($process.ExitCode))" -ForegroundColor Green | ||
| } else { | ||
| Write-Host "Installation failed with exit code: $($process.ExitCode)" -ForegroundColor Red | ||
| throw "ADK installation failed" | ||
| } |
There was a problem hiding this comment.
The script downloads an installer (via fwlink) and runs a silent install (/quiet) of the Windows ADK feature. That’s a high-risk pattern for a sample utility because it executes downloaded code without any explicit user confirmation or integrity verification. Consider removing auto-install and requiring manual install, or at minimum add an explicit opt-in prompt and validate the downloaded binary (e.g., Authenticode signature/publisher) before executing it.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Import the stable WPR and WPA profiles from main PR #602, link them from the repository documentation, and harden rundown conversion so it does not install system components or delete caller-owned CSV files. Record targeted validation and the administrator-only WPR capture follow-up. Source-commit: 177b65d Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Adding the log files needed for developers to capture Windows ML logs for diagnostic purposes. The instructions for using these logs will be published on Microsoft Learn after this PR is merged. Microsoft Learn docs are already authored and tested and reviewed.
Target Release
Immediately (applicable to 1.8).
Checklist
Note that /azp run currently isn't working for this repo.