I got a build in VSTS that are triggered on every commit in the repository. Everything works great with one exception.
We do not release a new version of the nuget package on every commit. So our nuget push build step fails with http status code 409. I've configured that step so that it can continue anyway.
Due to the error the build is just "partially successful". I'm using the a build badge which also states the same (without context).
How can I tell VSTS to ignore 409 or just replace the existing package (on nuget.org)?
The API key acts as an alias for the user account, so the same API key is used for all NuGet repositories within the repository manager.
You can configure your Azure DevOps Pipeline to publish packages to MyGet by adding NuGet build tasks to the pipeline configuration with the Azure DevOps UI or by adding a YAML file with the correct parameters to the root of your project's source code repo.
Look at package author in Visual Studio. Refer to nuget.org to look at package owners and number of downloads (and sometimes source code) If the package owners somewhat match the author in Visual Studio, and the package seems generally trusted in the community, then add the package reference.
Click “Advanced System Settings” then click the “Environment Variables” button located within the Advanced tab. From here double-click the PATH variable in the top panel and create a new entry by adding the path to the directory that contains your NuGet.exe file (in this instance it's C:/NuGet/).
Use -skipDuplicate
flag (available since NuGet 5.1):
(5.1+) If a package and version already exists, skip it and continue with the next package in the push, if any.
Source: https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-push#options
You can’t ignore 409 error in VSTS build and can’t replace the existing package in server.
I recommend that you can push the package in the release and fail the release if package is existing.
Another way is that, you can check the package in server before push package (e.g. PowerShell, REST API) during the build and set the condition for push package task (Custom Condition).
For example:
Update:
Allow duplicates to be skipped is supported in NuGet Push Task now! (Just check Allow duplicates to be skipped option in NuGet Push task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With