Whilst setting up a couple of Build Configurations in Teamcity recently I seemed to struggle with dependencies so I thought I best get this down.
Two Build Projects – Build A =Class Library, Build B = Console App (referencing Class Library in Build A)
Step 1 – Creating the Nuget Package Artifact (Build A – Class Library)
We need to make the class library DLL available as a nuget package. This can then be referenced through TeamCity’s Nuget server.
1.1 Create a new Build Step “Pack Class Assembly” – This should be the final step after the unit tests have passed.
1.2 Create a new “Snapshot Dependency” in the Console App (Build B).
1.3 Create a new build step on Console App (Build B) for the Nuget installer.
1.4 Authenticate Nuget feed
If your private Nuget feed requires credentials Nuget has a handy “Build Feature” that you can add to any project that requires access. Note that the user account should really be a service account.
1.5 Bring the Nuget feed into Visual Studio
Finally, it’s advisable to include the Nuget server location into Visual Studio to acquire the published assembly into any project that needs to reference it – This will be the same as the variable %teamcity.nuget.feed.auth.server%. For example