TFS Continuous Integration Build Trigger only one project in a solution - tfs

Is there a way to create a build definition, in TFS 2010, that uses continuous integration trigger, and only builds the project who's code changed.
To clarify, what I'm searching for is the following scenario:
1 Solution
x Projects in Solution
1 Build Definition per Project
All Builds are CI triggered
When a check-in occours in a project only that project gets built and tested.

Place in your build definition's "Items to build" section of the "Process" tab any *.*proj instead of a *.sln.
In the "Workspace" section, select only the source control paths that relate with this project.

In the process tab, set "Clean Workspace" to "None", use "/t:Build" on the "MSBuild Arguments" and properly configure your projects and their dependencies in the solution. This way on each build, you will be getting the latest code, and then building whatever was modified, and anything that depends on it. This is much more dynamic and requires only one build definition. Let the build system operate as it was designed and leverage the optimized build process.

Related

Using the same TFS build definition for multiple solutions

Our TFS 2013 admins have given us one build definition to build our solution and run all unit tests and they are not willing to create any more build definitions. We are following feature branch strategy and would like to use this build definition for our gated builds. I am trying to find how to use this one build definition with multiple branches.
I know, I can add all branches to Source settings and build them whenever a check-in is made. But I want to find out, if there is any way to add branches to Source settings, but only compile the solution that has been checked in. For example if we add 5 solutions to the Source settings, we want to compile only the solution that has changed rather than all 5 solutions.
You will need to setup an incremental build that only builds the solutions that have changed.
Ideally you will want to setup a build for every branch. You would still use the one build template given to you, but you would define the work-spaces and behavior differently for each branch depending on your needs. However if you do not have that option you can still implement what you are trying to do.
For example if you only want to build the solution that has changed you will set up your build to be an incremental build like the following:
In the "Process" tab update the "Items to build" section to any *.sln or *.*proj
In the "Workspace" section, select only the source control paths of each branch if setting up a build for every branch or select the entire source if that is how you have to do it ($/).
Change the build to an incremental build by changing the Build Process Parameters on the "Process" tab - CleanWorkspace=None
Tag one of the build agents, so that it is the only one used for these incremental builds. Set the build to only use this tagged agent. It is important that the same build agent or set of agents is used for the builds if incremental builds are to work.

Customize TFS Build to include only specific files

I have a solution file with multiple projects that I am trying to configure for continuous integration on a development server using Team Foundation Server. I would like to customize this to only deploy the changes that were checked in.
Scenario example
Projects
My Project (MVC app)
Logic Layer
A user checks in a new Home.cshtml file and updates a code file in the Logic Layer. I would like to configure the automated build to just build the following package:
My Project
bin/MyLogic.dll
Views/Home.cshtml
What steps are done to achieve this scenario?
You want an incremental build, though I don't recall if it was supported back in TFS 2010.
Try configuring the build to not clean the workspace. Set the "Clean Workspace" property in the "Basic" section to "None".
Then, it will keep the binaries from the previous build, and, just like Visual Studio, will only build targets for which the inputs have changed.

TFS Continuous Integration Build

I have created 3 continuous integration builds under same source control folder i.e under one TFS folder, there are 22 projects and 3 solutions under this folder, each solution contains some shared projects. I have created a continuous integration build for each of the 3 solution files. The problem is whenever anyone checks in under any solution all 3 builds are triggering. Is there any way to trigger the related build only if there is any check-in under the any solution ? Please let me know how to configure 'Items to build' and source setting tabs in TFS 2012 ?
TFS 2015u1 and older
The Source Control Folders in the mapping govern when a CI build triggers, nothing else. A custom Activity might be able to check that no changes were made in specific folders and prematurely stop the build, but that requires you to create a custom activity and customize the workflow.
Normally you'd place each solution and its projects in their own folder in Source Control, that way you can create a source control mapping for each specific CI build.
TFS 2015 update 2 and onwards:
The new build engine supports separate definitions for workspaces and triggers.

TFS 2012 automatically build projects that depend on current one

Ok so I have to admit, I'm very new to all of this build automation stuff. But basically what I'm wondering is if there is a way to wire up my build definitions in such a way that if I have a case like so
ProjectA produces ComponentA.dll
ProjectB references ComponentA.dll and produces ComponentB.dll
ProjectC references ComponentB.dll
then when I make changes to ProjectA and check them in, the build process would automatically also build ProjectB, and finally ProjectC, and report any errors.
So is there a way to accomplish this, or should this type of thing be handled somehow completely differently in the first place?
The process you are referring to is the crux of the practice known as Continuous Integration.
TFS does it very well: simply set your build definition Trigger to Continuous Integration and set the Workspace working folder to the parent folder of the three projects. This way, any change in one of the projects will trigger a build.
MSDN: Build and Deploy Continuously
You can use a visual studio solution and use project references between the projects. Then build the solution on your build server.

Filter projects which trigger build in tfs

Is there any within team build 2010 (tfs) to decouple the projects found under the build's workspace from the projects which will trigger a build?
I'd like to be able to specify a subset of the projects in my workspace as being those that trigger a build when changed. At the moment any change in the active paths of the workspace will trigger a build.
You can create more build definitions to build only specific projects. I had two sets of projects, framework and modules projects. I had two CI build definitions, one for framework set and one for modules. If I changed framework project, framework build was triggered and all output assemblies were checked-in into TFS into BuildAssemblies folder. This folder is included in Modules build definition workspace because BuildAssemblies are referenced from modules projects. Normally if I change BuildAssemblies content modules build should be triggered, but I checked my changes with ***NO_CI*** prefix to not trigger modules build.
But this is not good design. If you change framework assembly and break modules build by this change, you don't know about it until you manually trigger modules build. It makes no sense to use gated check-in feature for modules build.
In general, I tend to agree with John Saunders, still:
You can have the projects you wish to not trigger your build in a separate spot within your source control. Remove them from your main solution as projects & add them as assemblies.
This way, any change in your secondary sources will not trigger your main build - merging the compiled assembly will. The gain is that the latter can be done at any time you choose to.
Using file reference has several disadvantages in your case, the main being you can't directly debug the compiled assembly. See also here.
The only way is to remove those projects from the build definition's workspace mappings. The projects, of course, are still in the branch and your workspace.

Resources