Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a specific version of a package on a TeamCity Nuget Feed?

Does anyone know to remove a specific version of a package on a TeamCity Nuget Feed?

like image 832
matt_dev Avatar asked Apr 18 '12 21:04

matt_dev


People also ask

How do I publish a NuGet package to TeamCity?

When using TeamCity as a NuGet server, there are three ways to publish packages to the feed: as build artifacts of the NuGet Pack build step using the Publish created packages to build artifacts checkbox - in this case you do not need the NuGet Publish build step. via the NuGet Publish build step.

Can NuGet packages be deleted?

In exceptional situations such as copyright infringement and potentially harmful content, packages can be deleted manually by the NuGet team. You can report a package using the "Report abuse" button on the NuGet.org package details page.


3 Answers

This is now supported through the Web UI

Just remove the offending build by opening the build and choosing Actions > Remove. This removes the build from the list in TeamCity, and it also removes all build artifacts of that specific build from the Nuget feed.

like image 169
theDmi Avatar answered Sep 28 '22 07:09

theDmi


I know this was asked a long time ago but I still come across this problem every now and again and I always forget how to do it so I figured I would post my solution which I think might be slightly easier (depending on what way you look at it).

Basically, I ran a TeamCity build that unfortunately created a duff version of a 3rd party package that I tried to recreate but with a couple of modifications. It didn't work but it meant that I was always being presented with this duff package within the package manager and it will remain like this until the 3rd party releases a newer version. As such I wanted to delete the package from the TeamCity Nuget server and the only way I could find to do this was to delete the build which would also delete the artefacts (the duff Nuget package in this case).

Now, I couldn't see a way of deleting the build except with the REST API so that's what I used (I hope I'm not being stupid and there actually is an easy way of deleting builds from the UI). I used fiddler to generate the DELETE command. This was acheived by simply posting a delete request similar to what I've shown below:

From fiddler go to the Composer window. Select 'DELETE' instead of 'GET' and enter your TeamCity url in the form below:

http://<server>:<port>/httpAuth/app/rest/builds/<build ID> 

The build ID can be found by simply inspecting the URL when you select the build you want to delete from TeamCity (look for the number after the 'buildId' query parameter). The only other step was to add the authorization header to the command. Enter the following on the line below 'User-Agent' in the Request Headers window.

Authorization: Basic (Username:Password encoded as base64) 

To encode your username/password as base64 go to Tools->Text Wizard in fiddler and enter your TeamCity details in this format - Username:Password. Finally, you should select the 'Execute' button and all being well the build will get deleted along with the Nuget package.

This worked for me but obviously be careful when doing all this as you don't want to delete the wrong build. It may be prudent to backup/snapshot your TeamCity server first.

Hope this helps someone.

like image 34
King Roger Avatar answered Sep 28 '22 09:09

King Roger


First off, it appears that deleting ad-hoc NuGet packages is not directly supported in TeamCity yet. There is an open issue with JetBrains about it, but there is no fix currently planned. That said, we devised a work-around that got us past our specific problem, and may help with yours.

We had a series of nupkg files that used an incorrect (accelerated) version. Thus, they appeared to be "newer" than the packages we are creating now. Without a way to remove only the incorrect versions, we set each individual TeamCity build-configuration's "Clean Artifacts" policy to a short window (2 days) and ran Clean-up. You will need System Administrator privileges to do this.

This removed any artifacts one day older than the last artifact and cleaned out all our bad packages. We verified this through the NuGet command line List command. Since the more recent packages are correct, we are now only advertising good packages in our NuGet feed.

Admittedly, this is a "precision nuke" option and may not work for everyone. I hope TeamCity fully supports the NuGet command line API in the near future.

like image 29
SethO Avatar answered Sep 28 '22 08:09

SethO