How to include old builds in a NuGet feed?

I'm moving from an old build server to a new one. I want the NuGet feeds on the new server to include the packages from the old server. I've moved all the artefacts over but the NuGet feed does not include the old artefacts. I've found this page: NuGet Feed packages index should handle Artifact pattern cleanup (TW-5072) : TW-19411

It suggests I need to run a Ruby script to do this across all builds but that script fails with the following message:

C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/teamcity-rest-client-0.3.1/lib/teamcity-rest-client.rb:107:in `initialize': no implicit conversion of Hash into String (TypeError)

     open(url(path, params), @openuri_options).read
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/teamcity-rest-client-0.3.1/lib/teamcity-rest-client.rb:107:in `open'
       from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/teamcity-rest-client-0.3.1/lib/teamcity-rest-client.rb:107:in `get'
       from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/teamcity-rest-client-0.3.1/lib/teamcity-rest-client.rb:212:in `get'
       from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/teamcity-rest-client-0.3.1/lib/teamcity-rest-client.rb:197:in `builds'
       from tc-reindexall.rb:9:in `reindex_all'
       from tc-reindexall.rb:26:in `<main>'

Now I'm not sure where to turn!

0
8 comments

We had a similar problem, different circumstances, we wanted TeamCity to host some nuget packages that were built elsewhere.  As you probably know, if there isn't an existing build in TeamCity, or a build is deleted, the related package is also removed.

In the end, we created a build plan that was a package mirror plan, and all it did was download the original nuget package, unzip the contents, and then use a pack and publish task to fool TeamCity into thinking it's a their package. 😈

This works for a small number of packages, however might not be suitable for what you need.  Thought I would mention it, in case it works for you.

 

0
Hi Luke,

When you migrate a build server in TeamCity and want the NuGet feed on the new server to include the packages from the old server, simply moving the artifacts (e.g., .nupkg files) is not enough. The NuGet feed in TeamCity is dynamically generated based on build metadata and indexed artifacts. If the artifacts were copied manually, TeamCity doesn't recognize them as part of its NuGet feed.

TeamCity needs to re-index the artifacts to recognize the packages for its NuGet feed. How to index the NuGet Packages please refer to  https://www.jetbrains.com/help/teamcity/using-teamcity-as-nuget-feed.html#Indexing+packages+published+as+artifacts.

Please do not hesitate to reach out to me if you have any further inquiries regarding this matter.

Best Regards,
Tom
0

I'm not sure what I did but all of the NuGet packages from builds from the old server seem to have suddenly appeared in the list! I did the following for one build and then checked to see if was there. Then I noticed that they were all there. So I'm not sure at what point they all appeared…

curl -v -u username:password -X POST "http://localhost:8111/ajax.html?reindexMetadataBuildId=<buildnumber>

0

Does this survive a cleanup?

 

0

Clean up would remove the artifacts. I have clean up switched off.

0
Hi Luke,

I’m glad to hear that the NuGet packages are working for you! Did you try restarting the server? It seems to work properly after a TeamCity server restart.

If you have any further questions or need assistance, please don’t hesitate to reach out.

Best Regards,
Tom
0

To be honest, I wish I knew when it started working. Certainly early restarts didn't help but maybe it just took a while… I tried deleting buildMetadata directories etc. But I'm not sure exactly which step made it work!

0
Hi Luke,

I understand that sometimes these issues resolve unexpectedly, and it can be hard to pinpoint the exact action that worked. If you recall any additional details or encounter similar issues again, please feel free to let us know.

Best Regards,
Tom
0

Please sign in to leave a comment.