Azure Artifacts: "409 (Conflict - The feed already contains ...)"
The push stops with Response status code does not indicate success: 409 (Conflict - The feed already contains ...). The feed has that package ID at that version, and it never takes the same version twice. So the fix is in the version you push, or in which files you push, not in the feed's permissions.
Why deleting the version does not help
- From Microsoft's page on Azure Artifacts concepts: once a version of a package is published to a feed, that version number is reserved for good. You can't upload a new revision under the same number, and you can't delete it and publish a new package with that number.
- The rule belongs to the feed, so it holds for every package type in it. npm, Maven, Python and Universal Packages need a new version too.
When the push runs in a pipeline that a pull request waits on: Azure DevOps Pull Requests, a plugin for JetBrains IDEs, lists the pull request's branch policies with their state in IntelliJ IDEA, Rider or PyCharm, and with Pro runs a failed build policy again once the push is fixed.
Where the second push comes from
- The version doesn't change between builds. A fixed
<Version>in the project, or a pack step withversioningScheme: off, makes every run push the same version. The first run succeeds and every later one gets 409. - A run again. A run that pushed and then failed in a later step pushes the same version again when you run it again.
- Several packages in one push. When a pattern pushes every package of the solution, the packages whose version did not change conflict, and the push stops at the first one.
- The symbols package, twice.
nuget.exe pushpushes the.symbols.nupkgnext to the package along with it, and so doesdotnet nuget pushunless you add--no-symbols. A pattern that also matches the.symbols.nupkgthen pushes it a second time. The default pattern of the NuGet task leaves it out (...**/*.nupkg;!...**/*.symbols.nupkg); a custom**/*.nupkgbrings it back (azure-pipelines-tasks #1511).
Give each build its own version
- Versioning in the pack task. The pack command of the NuGet and .NET Core tasks takes
versioningScheme:byBuildNumber,byEnvVar, orbyPrereleaseNumber, which adds the date and time asX.Y.Z-ci-datetime(.NET Core task). - Or set it on the command line.
dotnet pack -p:PackageVersion=1.4.$(Build.BuildId)sets the version through the PackageVersion property (dotnet pack).
Skip the versions the feed already has
- task: NuGetAuthenticate@1
- script: dotnet nuget push "$(Build.ArtifactStagingDirectory)/*.nupkg" --source "https://pkgs.dev.azure.com/contoso/_packaging/contoso-feed/nuget/v3/index.json" --api-key az --skip-duplicate
dotnet nuget push --skip-duplicatetreats a 409 Conflict as a warning, so the other packages are still pushed (dotnet nuget push).nuget.exe push -SkipDuplicatedoes the same from NuGet 5.1 (push command).- The NuGet task (
NuGetCommand@2) hasallowPackageConflicts: true, which reports success when some packages are rejected with 409. Microsoft's page says it works only on Azure Pipelines with Windows agents and not behind a proxy, and that the task gets no new features; it points toNuGetAuthenticate@1with the .NET CLI, as above (NuGet task). - Skipping keeps the package that is already in the feed. When the content changed, the new content needs a new version.
Similar messages
- "Unable to load the service index for source" (NU1301): the feed refused the credentials, before any push.
- npm "E401 Unable to authenticate": the same kind of refusal for npm.
- "Dotnet command failed with non-zero exit code": the task's summary line; the cause is in the lines above it, which can be this 409.
Azure DevOps pull requests in IntelliJ IDEA, Rider and PyCharm
Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, reads the organization, project and repository from your git remote and lists the pull requests that wait for your review in an IDE tool window, on Azure DevOps Services and on Azure DevOps Server. It shows the branch policies of a pull request with their state, so a required build that has not passed is next to its pull request, and with Pro you run a failed or expired build policy again from there. The review inbox is free; voting, commenting, completing and creating are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Azure DevOps, Azure Artifacts and Azure Pipelines are trademarks of Microsoft Corporation; IntelliJ IDEA, Rider and PyCharm are trademarks of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.
More: Unable to load the service index for source · Dotnet command failed with non-zero exit code · Build validation · 日本語