How do I get an API key of the built-in NuGet server?

Answered

I need the API key, how can I find it ?

0
4 comments
Avatar
Permanently deleted user
0
Avatar
Permanently deleted user

Thanks, but I don't need the API key to publish package on the nuget built-in repository but to manage already published package, so I really need the API key for that.

We've made some test on nuget publication but now I would like to delete my test pakages from the nuget repository to clean it.

0
Avatar
Permanently deleted user

Hello,

The only way to remove packages is make the server to cleanup artifacts of a build or remove the build. There are more workarounds in TW-287.

0
Avatar
Permanently deleted user

>How do I get an API key of the built-in NuGet server?

To answer the question, you obfuscate the api key before outputting it so TC doesn't blank it out with asterisks.
e.g. add a powershell build script like this to get the api key output as a base64 string:

      Write-Host (  [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("%teamcity.nuget.feed.api.key%"))  )

Then go and look at the build log output and get the base64 string.
Once you have base64 decoded the key, (e.g. via https://www.base64decode.org/) you can then use the api key to nuget push from anywhere, e.g.

      NuGet.exe push ..\deploy\mynuget.1.2.3.nupkg my-really-long-teamcity-apikey -Source https://myteamcityserver/httpAuth/app/nuget/feed/_Root/default/v2

I'm not sure how retention would work, i.e. when it would get deleted - maybe never?

EDIT - I just gave this a quick try, and although the nuget push worked twice, on the third attempt it failed. On rerunning the script, it appears as though the api key changed, so it looks like you can only use the retrieved key in a limited time window.

0

Please sign in to leave a comment.