Skip to content

Capture the PowerShell Gallery package as a build artifact#2780

Merged
nohwnd merged 1 commit into
mainfrom
capture-psgallery-nupkg
Jun 28, 2026
Merged

Capture the PowerShell Gallery package as a build artifact#2780
nohwnd merged 1 commit into
mainfrom
capture-psgallery-nupkg

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 28, 2026

Copy link
Copy Markdown
Member

Problem

The publish pipeline artifact only contained the nuget.org/Chocolatey nupkg (tmp/nuget/Pester.<version>.nupkg), never the PowerShell Gallery one.

Publish-Module packs the gallery module into a random system temp folder and discards it after the push:

C:\Users\VssAdministrator\AppData\Local\Temp\821736127\Pester\Pester.6.0.0-rc1.nupkg

That path is outside tmp/, so the artifact upload (which captures tmp/) never sees it. When the gallery push fails — as it did with 403 (The specified API key is invalid, has expired, or does not have permission...) — the agent is torn down and the signed package is gone. Nothing overwrites it; it's simply never written under tmp/.

Fix

Before the gallery push, pack the module into tmp/PSGallery-package/ via a temporary local PSRepository. This produces the exact PowerShell Gallery–format .nupkg (same packing logic as Publish-Module) and saves it where the pipeline artifact already looks, so it's captured even when the gallery push fails.

The capture is wrapped in try/catch/finally so its own failure never blocks the real publish, and the temporary repository is always unregistered.

After this, the artifact contains:

pester-packages/
  nuget/             Pester.<version>.nupkg   (nuget.org + Chocolatey)
  PSGallery-package/ Pester.<version>.nupkg   (PowerShell Gallery)  ← new
  PSGallery/Pester/  (unpacked module folder)

Note

The 403 means the PsGalleryApiKey variable in the AzDO signing group is invalid/expired and needs rotating. This PR doesn't fix that — it ensures the signed gallery package is always downloadable so it can be published manually in the meantime.

Pipeline stays trigger: none (manual), so this applies on the next publish run.

… artifact

Publish-Module packs the gallery module into a random system temp folder (e.g. %TEMP%\<random>\Pester\Pester.<version>.nupkg) and discards it after the push. When the gallery push fails, that signed package is lost and never lands under tmp/, so the publish pipeline artifact only contained the nuget.org/Chocolatey nupkg.

Pack the gallery module into tmp/PSGallery-package via a temporary local repository before the gallery push, so the exact .nupkg we publish is always captured as a build artifact - even when the push fails. The capture is wrapped so its own failure never blocks the real publish.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd
nohwnd merged commit fdfa8fc into main Jun 28, 2026
3 of 12 checks passed
@nohwnd
nohwnd deleted the capture-psgallery-nupkg branch June 28, 2026 10:40
@fflaten

fflaten commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

AFAIK you could simplify this with Compress-PSResource and Publish-PSResource -NupkgPath ..., though haven't tested it personally

@nohwnd

nohwnd commented Jun 28, 2026

Copy link
Copy Markdown
Member Author

I am just stupid and forgot that powersehll modules are published from folder, not as nupkg, that is why I am hunting it.

@nohwnd

nohwnd commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

@fflaten thanks, this made me realize the whole gallery capture is pointless. The gallery is published from the module folder, not a nupkg, so there is nothing to capture there. The packaged nupkg only goes to nuget and choco. Reworked it in #2910, it drops the gallery capture and puts the nuget and choco packages into their own named folders.

🤖

nohwnd added a commit that referenced this pull request Jul 19, 2026
When a publish fails I want to grab the exact built package from the pipeline artifact and push it by hand. So put each target's package in its own folder under tmp: tmp/nuget.org and tmp/chocolatey for the signed nupkg. tmp/PSGallery/Pester stays the folder we publish to the gallery.

Also drop the gallery capture from #2780. The gallery is published from the module folder, not a nupkg, so that captured package was never something we publish.

🤖
nohwnd added a commit that referenced this pull request Jul 19, 2026
When a publish fails I want to grab the exact built package from the pipeline artifact and upload it to psgallery, nuget or choco by hand. So put each target's package in its own folder under tmp: tmp/nuget.org and tmp/chocolatey for the signed nupkg, and tmp/PSGallery/Pester stays the folder we publish to the gallery.

Also keep going when a feed fails instead of aborting on the first error. Before this a failed gallery push skipped nuget and choco. Now each push runs in its own try/catch, the failures are collected, and the build fails at the end listing which feeds to redo by hand.

And drop the gallery capture from #2780. The gallery is published from the module folder, not a nupkg, so that captured package was never something we publish.

🤖
nohwnd added a commit that referenced this pull request Jul 19, 2026
…er (#2910)

When a publish fails I want to grab the exact built package from the pipeline artifact and upload it to psgallery, nuget or choco by hand. So put each target's package in its own folder under tmp: tmp/nuget.org and tmp/chocolatey for the signed nupkg, and tmp/PSGallery/Pester stays the folder we publish to the gallery.

Also keep going when a feed fails instead of aborting on the first error. Before this a failed gallery push skipped nuget and choco. Now each push runs in its own try/catch, the failures are collected, and the build fails at the end listing which feeds to redo by hand.

And drop the gallery capture from #2780. The gallery is published from the module folder, not a nupkg, so that captured package was never something we publish.

🤖
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.

2 participants