Open Smaug123 opened 3 months ago
Note to maintainers: this issue was originally opened at https://github.com/dotnet/sdk/issues/41284 as a feature request for dotnet CLI.
I've worked around the lack of this feature by pushing a dummy package with --skip-duplicate
. The exit code will be 0 if everything worked, including if the package already exists.
EDIT:
You cannot push PackageId
"DUMMY" to Nuget.org without Write access to https://www.nuget.org/packages/DUMMY/.
--dry-run
functionalityDry run functionality for nuget pushes should be identical to a normal push, aside from the fact that the package should not be published after it is green-lit.
Without a --dry-run
argument, your Release pipeline should...
--skip-duplicates
. Aside from a "dummy" version, these should be identical to the packages you publish later.
dotnet pack $(MSBuildProjectFullPath) --configuration Release --p:Version=0.0.1-DUMMY --skip-duplicates -o ./$(YourDummyNupkgsDirectory)/$(PackageId)
(include symbols if desired).dotnet nuget push --source $(Source) --api-key $(ApiKey) "$(YourDummyNupkgsDirectory)/$(PackageId)"
to push the dummy packages with to each source, using the correct key for each push. This seems odd, but it accounts for when you push multiple packages to one source and each package requires a different key.
NuGet Product(s) Involved
dotnet.exe
The Elevator Pitch
Is your feature request related to a problem? Please describe.
I recently discovered only after a push to
main
that mydotnet nuget push
command line was incorrect (I specified--skip-duplicates
, a typo for--skip-duplicate
).Describe the solution you'd like
A new option:
--dry-run
, which does everything short of actually pushing the package.Additional Context and Details
Additional context
It's normal for tools to offer
--dry-run
; for example,git push --dry-run
,cargo publish --dry-run
,npm publish --dry-run
.When writing automated pipelines to run in privileged environments, it's extremely helpful to be able to run the same pipeline in an unprivileged environment; the main alternative is to set up an entire parallel infrastructure (e.g. a separate NuGet repository), which is dramatically more work for the user. Concretely, if I could run
dotnet nuget push ${DRY_RUN:+--dry-run}
then I could have exactly the same code running on branches as onmain
.