Capture the PowerShell Gallery package as a build artifact#2780
Merged
Conversation
… 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>
Collaborator
|
AFAIK you could simplify this with |
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. |
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. 🤖
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The publish pipeline artifact only contained the nuget.org/Chocolatey nupkg (
tmp/nuget/Pester.<version>.nupkg), never the PowerShell Gallery one.Publish-Modulepacks the gallery module into a random system temp folder and discards it after the push:That path is outside
tmp/, so the artifact upload (which capturestmp/) never sees it. When the gallery push fails — as it did with403 (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 undertmp/.Fix
Before the gallery push, pack the module into
tmp/PSGallery-package/via a temporary localPSRepository. This produces the exact PowerShell Gallery–format.nupkg(same packing logic asPublish-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:
Note
The
403means thePsGalleryApiKeyvariable in the AzDOsigninggroup 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.