Build projects when dependency changes

Answered

Hi, we've just had a situation where a project that builds a DLL (Core.sln) was changed and rebuilt, but the 'top level project' (Processor.sln) was not rebuilt. This is how it's been set up, but now we've seen that it doesn't fulfil our needs, we need to change the projects so that a change to Core will cause all the top-level projects that depend on it to be rebuilt.

The TeamCity documentation says that the way it works is that when you build a top-level project, it makes sure that all the dependencies are up to date, while we want the opposite - each time a project is built, rebuild all the other projects that depend on it.

I did originally have Finish Build Triggers setup on each of the dependencies which would build the higher-level projects that depended on it. Unfortunately, that just kept filling the Build Queue and re-triggering builds that had already been completed.

So, the question is - how have other people solved this "if project changes, build all other projects which depend on it" problem?

Thanks

Richard

0
3 comments

Hi Richard,

 

if your build configurations are tied via snapshot dependencies, you can set their policy to always run a new build instead of reuse when a suitable is available.

 

Additionally, instead of using finish build triggers, we would recommend to simply set a VCS Trigger at the very end of the build chain (or at the last step that should be triggered automatically, in case you want to have manual components such as publishing), and set it to trigger on changes in snapshot dependencies if required. This will tell TeamCity that whenever a change is found in the VCS Roots throughout the chain, the full chain should be triggered, and since the policy for the dependencies is to rebuild instead of reuse, everything should be built again.

 

Could you check if it works for you?

0

Thanks Denis, that's a nice solution. I'll try that when I get time

Richard

0

A very late response, but I have just got some time to look at this again. If we have 3 projects (ProjectA, ProjectB and ProjectC) all depending on Core.dll and set them up as above (VCS trigger on each of ProjectA, ProjectB, ProjectC), with snapshot dependency in each on Core.dll, will that cause Core.dll to be rebuilt 3 times if Projects A, B and C ALL have changes in their VCS?

Am I right in thinking that the solution above will build ProjectA, B and C if it detects a change in Core.dll? Or will it wait until ProjectA (for example) changes before rebuilding Core?

Thanks

Richard

0

Please sign in to leave a comment.