Enhance NuGet package push scripts to track failed packages by logging them to a file#25261
Conversation
…s to a dedicated file, enhancing error tracking and management.
There was a problem hiding this comment.
Pull request overview
This PR enhances the NuGet package push scripts under nupkg/ to persist the list of failed package pushes into a failed-packages.txt file, making it easier to identify which packages need re-publishing.
Changes:
- Add
failed-packages.txtoutput for failed package pushes in the main NuGet push script. - Add
failed-packages.txtoutput for failed package pushes in the nightly MyGet push script. - Ensure any previous
failed-packages.txtis removed at script start to avoid stale results.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| nupkg/push_packages.ps1 | Writes failed package names to failed-packages.txt when the script exits with errors. |
| nupkg/push-nightly-packages-myget.ps1 | Writes failed nightly package names to failed-packages.txt when pushes fail. |
| if ($errorCount > 0) | ||
| { | ||
| Write-Host ("******* $errorCount error(s) occured *******") -ForegroundColor red | ||
| $failedPackages | Set-Content -Path $failedPackagesFilePath |
There was a problem hiding this comment.
$errorCount is incremented for missing packages ("ERROR PACKAGE NOT FOUND"), but those package names are never added to $failedPackages. As a result, failed-packages.txt can be empty even when the script fails. Consider adding $nugetPackageName (or a clearer identifier) to $failedPackages in the not-found branch so the file reliably captures all failures.
| if ($errorCount > 0) | ||
| { | ||
| Write-Host ("******* $errorCount error(s) occured *******") -ForegroundColor red | ||
| $failedPackages | Set-Content -Path $failedPackagesFilePath |
There was a problem hiding this comment.
Set-Content uses different default encodings between Windows PowerShell (UTF-16LE) and PowerShell 7+ (UTF-8), which can make failed-packages.txt harder to consume in CI tools. Consider specifying an explicit encoding (e.g., UTF-8) when writing the file for consistent output across environments.
| $failedPackages | Set-Content -Path $failedPackagesFilePath | |
| $failedPackages | Set-Content -Path $failedPackagesFilePath -Encoding utf8 |
| { | ||
| $errorCount = $failedPackages.Count | ||
| Write-Host ("******* $errorCount error(s) occured *******") -ForegroundColor red | ||
| $failedPackages | Set-Content -Path $failedPackagesFilePath |
There was a problem hiding this comment.
Set-Content uses different default encodings between Windows PowerShell (UTF-16LE) and PowerShell 7+ (UTF-8), which can make failed-packages.txt harder to consume in CI tools. Consider specifying an explicit encoding (e.g., UTF-8) when writing the file for consistent output across environments.
| $failedPackages | Set-Content -Path $failedPackagesFilePath | |
| $failedPackages | Set-Content -Path $failedPackagesFilePath -Encoding utf8 |
No description provided.