Search code examples
.netbuildcontinuous-integrationteamcityprojects-and-solutions

How to Build Multiple Dependent .NET Solutions in TeamCity?


We've got an application which components are developed in multiple Visual Studio solutions (.sln). From time to time a solution is added or removed. The build output such as DLLs are copied into a shared folder. Projects from other solutions reference those DLLs. Here's a simplified example: solutions A and B consist of two projects each. The project B2 of solution B references project A2 of solution A.

enter image description here

Side note: We're in the process to replace the shared drive with NuGet packages; however, the following question is still apparent.

TeamCity supports build dependencies. This video demonstrate how to set it up manually.

However, we would like TeamCity to automatically(!!) resolve dependencies between projects. So in the above example we'd like that TeamCity builds solution A first and solution B next. How can we configure TeamCity to pick up these dependencies automatically without maintaining them manually?


Solution

  • Unfortunately it can't automatically. You can consider writing your own plugin.

    You would usually setup a snapshot dependency, in your example B build would have a snapshot dependency on A build.

    In the case of when you have moved to NuGet, it will restore whatever the solution is referencing. You might want to have snapshot dependency like above but not required, each solution would determine what it needs.

    Update 1 - Automating

    I think you should be able to do it with the Rest API, documentation is not very clear but I did find this gist which has an example of adding and deleting snapshots.

    You'll probably need to work out some convention that projects are setup with to make it easier to match projects.

    You should also checkout the plugins page for libraries that abstract the API.