TFSBuild.proj File and Build Process Customization

TFSBuild.proj file is used to customize and tailor Build process according to our needs. One of the most useful and handy customization is configuration of the build execution plan. For example, you are working on a very large project that requires a long time to build and if you use continues build this will be a real problem to wait a long time for each build is complete upon each check in into source safe, so you may want to build only updated files versus entire project. TFS provides very handy functionality to do just that.

You need to update TFSBuild.proj file in order to build files that were changed. Following XML statement do just that. This XML code snippet needs to be added into the TFSBuild.proj file.
<Target Name="ShortBuild" Inputs="@(CSFile)" Outputs="$(AppName).exe" >
    <CSC Sources="@(Compile)" OutputAssembly="$(AppName).exe" />


Process of specifying only recently changed files for the build is called Incremental Build and can be very useful when large team is working on a large project.

SkipClean – removes files and folders before building the target.
SkipInitializeWorkspace – removes old workspace and recreates new one.
ForceGet – replaces source files with new files from the workspace.

In order to perform customization to the TFSBuild.proj file you need to follow very distinct steps. They are:

  1. Run tf add Custom.dll
  2. Run tf checkin Custom.dll
  3. Checkout and update TFSBuild.proj
  4. Save and checkin TFSBuild.proj

Another good example of utilizing TFSBuild.proj is when we need to add custom task that executes after project completed build. For instance, we could send an email that project build was done. In this case, we need to create custom task and store it in the CustomTask.dll, store this item under source control within the same node as team project and register our custom task with TFSBuild.proj file
<Target TaskName="SendEmail" AssemblyName="CustomTask" />

We also need to add custom task via the following XML code
<Target Name="AfterEndToEndIteration">
    <SendEmail />

We can start build process from the command line with the help of the command line tool called TFSBuild. In order to start up build process on the server we specify Server name, Project Name and target Build machine.
TFSBuild start http://TFSProject:8080 MyTeam MyProject /machine:TFSBuildMachine

Same line of code can be executed from within Windows Scheduler as explained above.

However, TFSBuild cannot be used if we want to remove Build Type from the TFS. We need to use Team Explorer to remove Build Type.

In order to perform Build Type removal, you need to navigate to the View many, click on Other Windows and select Source Control Explorer. In the folder pane, select the build type folder that you want to remove. Normally it is located under Team Project\Team Build Types\[Build Type Name]\ folder. After folder is selected choose delete from shortcut menu to remove build type entry.

Featured pages

SharePoint Integration

Windows SharePoint Services is an integral part of Team Foundation Server. As a result, there is v…

Creating Team Project

Team Foundation Server allows creation of the portal project via TFS Portal Creation Wizard. This …

SQL Server Agent Jobs

Team Foundation Server installs several SQL Server Agent Jobs that allow it to perform certain tas…

tf Command

tf Command line utility provide many useful operations that we can perform with Team Foundation Se…

Shelving and Unshelving

Shelving is very powerful feature of the Source Control in VSTS that allows storing pending change…

MS Project Fields Mapping

TFS works with MS Project via mapping file with specific fields mapped from one application to ano…

Using MS Project with Team Foundation Server

MS Projects allows accessing Team Foundation Server and working with the TFS Work Items. This is a…

Managing Documents in TFS

Team Foundation Server provides us with the capability to manage various documents, also called ar…