Out of the box Team Build does not support Delta Builds. Thomas Janssen has a detailed post Realizing Delta Builds with VSTS Team Build for Delta Deployments which describes how this can be achieved. I have not had the opportunity to try this myself, but the blog post looks very through and informative. You can also download his DeltaBuild.targets file from his blog. I have the following comments relating to this; perhaps he will upgrade this file to reflect these comments.
This guidance is appropriate for target files which are designed to be consumed by others.
Don't override targets like AfterCompileSolution
Don't override targets like AfterCompileSolution. Instead extend the CompileSolutionDependsOn property in the manner:
<PropertyGroup>
<CompileSolutionDependsOn>
$(CompileSolutionDependsOn);
DeltaAfterCompileSolution
CompileSolutionDependsOn>
PropertyGroup>
This is because some consumers of this file may have already defined the AfterCompileSolution target. In which case one of them will be overridden.
Notice that I named the new target DeltaAfterCompileSolution. It is a best practice to prefix your targets with a value that should be unique. This will minimize the chances of your targets colliding with those defined by others. For example this could have been named MyAfterCompileSolution, but I bet there are a bunch of these already defined.
DependsOnTargets should always be taken from a property
You should define the DependsOnTargets value inside of a property, just like the MSFT targets files do. For example your DeltaAfterCompileSolution (after being renamed) would look like this:
<PropertyGroup>
<DeltaAfterCompileSolution>
$(DeltaAfterCompileSolution);
SafeCleanBuildResult;
GetLatestVersion;
CollectIncrementalBuildResult;
CreateDeltaBuildResult
DeltaAfterCompileSolution>
PropertyGroup>
<Target
Name="DeltaAfterCompileSolution"
DependsOnTargets="$(DeltaAfterCompileSolution)">
Target>
This is because you want users to be able to extend this process similar to how users extend the built-in build process. Without this they may need to modify your file, which is ill-advised because you may make a new release at some point.
Also notice the usage of the $(DeltaAfterCompileSolution) in the declaration of the DeltaAfterCompileSolution property. This is to
preserve any previous values that the user may have defined.
On a side note, if you are looking for more detailed information regarding Team Build, there will be three chapters of my new book Inside the Microsoft® Build Engine: Mastering MSBuild and Team Build which will be published in January 2009. Sample chapters will be available at that link shortly.
Thanks,
Sayed Ibrahim Hashimi
Comments are closed.