Search code examples
powershellnugetartifactorybintray

Publish Powershell module to bintray nuget repo


I created a nuget repository in bintray and I'd like to publish a Powershell module. I've created a package in Bintray and added a version.

First, I added the repository:

Register-PSRepository -Name "Bintray" -SourceLocation "https://api.bintray.com/nuget/{organization}/{repository}" -PublishLocation "https://api.bintray.com/nuget/{organization}/{repository}" -InstallationPolicy Trusted

Then, I try to publish:

Publish-Module -Path . -Repository "Bintray" -NugetApiKey {MyApiKey}

Publish-PSArtifactUtility : Failed to publish module 'MyModule': 'Response status code does not indicate success: 401 (Unauthorized)'

I've checked my API key, my user is a "member" and members have "Publish" rights on the repository. There are no restrictions on the repository. The name of the package in Bintray matches the name of the module I'm trying to publish.

I've also tried appending -Credential {UserName} to the publish command, and entering my password when prompted. The result is always the same.

What did I miss? How can I publish a Powershell module to a Bintray nuget repo?


Editing to update: when I try with the bintry account admin, I instead get error 405 "Not Allowed". This is true using PowerShell Publish-Module and calling nuget directly. curl gives me a 400 error: "Error occurred while uploading", as does bintray-cli. The web UI gives a generic error message.

This article says it works with Artifactory; and jfrog calls bintray a "full fledged nuget repository". So why doesn't this work?


Solution

  • After properly specifying the authentication information and URLs, I landed with the 400 / 405 error detailed in the question edit ("Error occurred while uploading").

    We determined that the failure was caused by the <tags> element in the package .nuspec file exceeding 1024 characters. This is not a published limitation, or an inherent limitation of the format (nuget.org advertises that they support a maximum of 4000 characters). Removing or truncating the tags allows the package to be uploaded to bintray.