Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

NuGet publish workflow fails when .snupkg symbols packages don't exist, despite .nupkg being pushed successfully. The wildcard handling in cmd causes non-zero exit codes on missing files.

Changes

  • Converted publish step to PowerShell for explicit file existence checks
  • Separated .nupkg and .snupkg push logic
    • .nupkg: fails if none found (required)
    • .snupkg: skips with message if none found (optional)
  • Individual file iteration with per-package error handling

Implementation

- name: Publish to NuGet
  run: |
    # Check for .nupkg files (must exist)
    $nupkgFiles = Get-ChildItem -Path "Build\nuget\*.nupkg" -ErrorAction SilentlyContinue
    if ($null -eq $nupkgFiles -or $nupkgFiles.Count -eq 0) {
      Write-Error "No .nupkg files found in Build\nuget\"
      exit 1
    }
    
    # Push all .nupkg files
    foreach ($pkg in $nupkgFiles) {
      & "3rdParty\nuget\nuget.exe" push $pkg.FullName -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
      if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
    }
    
    # Check for .snupkg files (optional)
    $snupkgFiles = Get-ChildItem -Path "Build\nuget\*.snupkg" -ErrorAction SilentlyContinue
    if ($null -eq $snupkgFiles -or $snupkgFiles.Count -eq 0) {
      Write-Host "No .snupkg found - skipping."
    } else {
      foreach ($pkg in $snupkgFiles) {
        & "3rdParty\nuget\nuget.exe" push $pkg.FullName -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_API_KEY }}
        if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
      }
    }
  shell: pwsh

Workflow now succeeds when .snupkg doesn't exist while maintaining failure on missing .nupkg.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix workflow failure: Publish step should not fail when no .snupkg exists</issue_title>
<issue_description>We successfully publish the NuGet package, but the GitHub Actions workflow still fails in the “Publish to NuGet” step because it tries to push a symbols package (*.snupkg) that is not produced.

Evidence / log excerpt:

  • "Your package was pushed."
  • then: "File does not exist (Build\nuget*.snupkg)."
  • "Error: Process completed with exit code 1."

So the publish succeeded, but the job is marked as failed due to the missing .snupkg.

Goal:
Make the publish step robust:

  • Always push Build\nuget*.nupkg (as today)
  • Only push Build\nuget*.snupkg if at least one exists
  • If no .snupkg exists, skip symbols publishing and keep the job green

Constraints:

  • Do NOT change build/pack behavior, versioning, or triggers
  • Do NOT switch packaging approach (keep current nuget pack / .nuspec flow)
  • Keep using 3rdParty\nuget\nuget.exe and the existing NUGET_API_KEY secret

Implementation notes:
Update the workflow file that contains the publish commands (e.g. .github/workflows/build-nuget.yml). Replace the publish step so it:

  1. Fails if no .nupkg exists (this should remain an error)
  2. Pushes all .nupkg files found
  3. Checks whether any .snupkg exists and only then pushes those; otherwise prints: "No .snupkg found – skipping."

Preferred approach:
Use PowerShell (shell: pwsh) with Get-ChildItem and proper error handling to avoid wildcard behavior in cmd causing non-zero exit codes.

Acceptance criteria:

  • Workflow run pushes the .nupkg successfully
  • Workflow does not fail when no .snupkg exists
  • If a .snupkg exists in Build\nuget, it is pushed as well
    </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: reneschulte <7439129+reneschulte@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix workflow failure for missing .snupkg during publish Fix publish step to handle missing .snupkg gracefully Feb 2, 2026
Copilot AI requested a review from reneschulte February 2, 2026 08:58
@reneschulte reneschulte marked this pull request as ready for review February 2, 2026 09:07
@reneschulte reneschulte merged commit 81eb25f into master Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix workflow failure: Publish step should not fail when no .snupkg exists

2 participants