S⚠️ ◾ Automated Package Update#820
Conversation
This script updates NuGet package versions in the Directory.Packages.props file by querying the latest available versions and updating the Version attributes accordingly, while respecting the PreserveMajor attribute and pre-release version detection.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Changed the trigger for package updates to a scheduled cron job.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan * Gate PR creation on changes detection flag Co-authored-by: neilr81 <49037171+neilr81@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: neilr81 <49037171+neilr81@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed GitHub CLI installation step from workflow.
Removed the 'powershell' label from the automated package update PR.
PR Metrics✔ Thanks for keeping your pull request small.
Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs! |
There was a problem hiding this comment.
Pull request overview
Automates NuGet package version updates by adding a scheduled GitHub Actions workflow and a PowerShell updater script, and applies an initial MSTest package bump via central package management.
Changes:
- Update MSTest package versions in
Directory.Packages.props(and reformat PackageVersion entries). - Add
.github/scripts/Update-NuGetPackageVersions.ps1to updateDirectory.Packages.propsby querying latest package versions. - Add
.github/workflows/package-update.ymlto run the script on a schedule and open a PR automatically.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Directory.Packages.props | Bumps MSTest versions and normalizes XML formatting for PackageVersion entries. |
| .github/workflows/package-update.yml | Adds scheduled automation to run the updater script and create a PR. |
| .github/scripts/Update-NuGetPackageVersions.ps1 | Implements package version discovery and updates for Directory.Packages.props. |
| echo "has-changes=true" >> $env:GITHUB_OUTPUT | ||
|
|
||
| - name: Open PR with gh | ||
| if: steps.commit.outputs.has-changes == 'true' |
There was a problem hiding this comment.
has-changes output key contains a hyphen, but the if: expression uses dot-notation (steps.commit.outputs.has-changes). In GitHub Actions expressions, keys with - should be accessed via bracket notation (e.g., steps.commit.outputs['has-changes']) or renamed to an identifier-safe key (e.g., has_changes), otherwise the condition may not evaluate as intended.
| if: steps.commit.outputs.has-changes == 'true' | |
| if: steps.commit.outputs['has-changes'] == 'true' |
| # Prefer NuGet-GitHub.Config (used on GitHub runners) when present, otherwise fall back to NuGet.config | ||
| $nugetGithubConfigPath = Join-Path $SourcesDirectory "NuGet-GitHub.Config" | ||
| $nugetConfigPath = Join-Path $SourcesDirectory "NuGet.config" | ||
| $configSourceFlag = "" | ||
| if (Test-Path $nugetGithubConfigPath) { | ||
| $configSourceFlag = "--configfile `"$nugetGithubConfigPath`"" | ||
| if ($EnableVerboseLogging) { | ||
| Write-Host " [VERBOSE] Using NuGet-GitHub.Config from: $nugetGithubConfigPath" | ||
| } | ||
| } | ||
| elseif (Test-Path $nugetConfigPath) { | ||
| $configSourceFlag = "--configfile `"$nugetConfigPath`"" | ||
| if ($EnableVerboseLogging) { | ||
| Write-Host " [VERBOSE] Using NuGet.config from: $nugetConfigPath" | ||
| } | ||
| } | ||
| else { | ||
| Write-Warning "NuGet-GitHub.Config or NuGet.config not found at: $SourcesDirectory - search may not find required feeds" | ||
| } |
There was a problem hiding this comment.
The repo contains NuGet.Config (capital C), but the script falls back to NuGet.config. On case-sensitive filesystems this will fail to locate the config and may search the wrong feeds. Use the correct filename casing (NuGet.Config) in both the path and log messages.
| if ($firstVersionObject.Version -eq $secondVersionObject.Version) { | ||
| if (-not $firstVersionObject.Suffix) { return $First } | ||
| if (-not $secondVersionObject.Suffix) { return $Second } | ||
| if ($firstVersionObject.Suffix -lt $secondVersionObject.Suffix) { return $Second } | ||
| return $First | ||
| } | ||
|
|
||
| if ($firstVersionObject.Version -lt $secondVersionObject.Version) { return $Second } | ||
| return $First |
There was a problem hiding this comment.
Pre-release comparison uses a plain string compare on the suffix ($firstVersionObject.Suffix -lt $secondVersionObject.Suffix). This can select the wrong “latest” version for common SemVer patterns (e.g., -preview.10 vs -preview.9). Use a SemVer-aware comparison for prerelease identifiers (or a NuGet version parser) so updates don’t regress to an older prerelease.
| on: | ||
| schedule: | ||
| - cron: "0 6 * * 1" | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
There was a problem hiding this comment.
The workflow is configured to run on pull_request events, but this job creates and pushes a new branch and opens a PR. That can create unexpected PRs/branches for every incoming PR, and will also fail for forked PRs where secrets (and often write permissions) aren’t available. Consider removing the pull_request trigger and using only schedule/workflow_dispatch (or gate the PR-creation steps to run only on scheduled/manual runs).
This PR was created automatically by the workflow run 21805900574.