Hi everyone,
I’ve been using the “dotnet nuget push” command with the “–skip-duplicate” flag. As I understand it, if the NuGet package already exists in the repository, it should return a “Conflict” (409) HTTP status code. However, I’m encountering an issue where my Nexus NuGet Hosted Repository returns a “Bad Request” (400) status code instead.
dotnet nuget push ".\Published\MyPackage.0.1.0.nupkg" -s http://my-nexus.local/repository/nuget/index.json -k <api-key> --skip-duplicate
# warn : You are running the 'push' operation with an 'HTTP' source, 'http://my-nexus.local/repository/nuget/index.json'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
# Pushing MyPackage.0.1.0.nupkg to 'http://my-nexus.local/repository/nuget'...
# warn : You are running the 'push' operation with an 'HTTP' source, 'http://my-nexus.local/repository/nuget/'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
# PUT http://my-nexus.local/repository/nuget/
# BadRequest http://my-nexus.local/repository/nuget/ 92ms
# error: Response status code does not indicate success: 400 (Bad Request).
#
#
# Usage: dotnet nuget push [arguments] [options]
#
# Arguments:
# [root] Specify the path to the package and your API key to push the package to the server.
#
# Options:
# -h|--help Show help information
# --force-english-output Forces the application to run using an invariant, English-based culture.
# -s|--source <source> Package source (URL, UNC/folder path or package source name) to use. Defaults to DefaultPushSource if specified in NuGet.Config.
# -ss|--symbol-source <source> Symbol server URL to use.
# -t|--timeout <timeout> Timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).
# -k|--api-key <apiKey> The API key for the server.
# -sk|--symbol-api-key <apiKey> The API key for the symbol server.
# -d|--disable-buffering Disable buffering when pushing to an HTTP(S) server to decrease memory usage.
# -n|--no-symbols If a symbols package exists, it will not be pushed to a symbols server.
# --no-service-endpoint Does not append "api/v2/package" to the source URL.
# --interactive Allow the command to block and require manual action for operations like authentication.
# --skip-duplicate If a package and version already exists, skip it and continue with the next package in the push, if any.
#
HTTP/1.1 400 Bad Request
...
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>400</code>
<message xml:lang="en-US">Repository does not allow updating assets: nuget</message>
</error>
Has anyone else faced this issue or can anyone provide guidance on how to resolve this so that the correct status code is returned?
Thanks in advance for your help!