In TFS 2008 when we create custom tasks (inherits from Task class), we get a log object which helps us log messages into the log file of the build (with LogMessage method).
In TFS 2010 the Team Build is based on workflow, so when we create a code activity we inherit from Activity class that does not contain log object. Not even a log method. Instead, we have context object (of CodedActivityContext class) that has Track method that can execute another activity.
We can Create new WriteBuildError Activity object (from the toolbox) and pass it to Track method. When running the build, we will have new line in the build log with our message.
A better way to do it is to use Microsoft.TeamFoundation.Build.Workflow.Activities namespace that contains extension methods for the context. After adding the using statement, you'll notice 3 new methods of the context called TrackBuildError, TrackBuildWarning and TrackBuildMessage. Enjoy!
Most of my customers want their Drop Location folders organized in sub-folders for each solution instead of getting all DLLs\EXEs in one massy folder.
Instead of customizing csproj as http://stackoverflow.com/questions/2784335/how-can-i-get-tfs-2010-to-build-each-project-to-a-separate-directory and http://social.msdn.microsoft.com/Forums/en/tfsbuild/thread/a62a6f98-ec44-46c1-a0d0-7f441f0db973 suggest, you can update the template of your build and change the output directory to the one you want.
First, open the XAML template and drill down to the compilation activity:
You have Run-MSBuild-for-Project activity. In the Properties window check out the OutDir parameter – That's the one you want to change!
By default, this parameter has outputDirectory variable which directs to Binaries folder of the build in the build machine.
i.e I created a build name TestBuild.
The default OutDir value is D:\Builds\4\Project2010\TestBuild\Binaries
Now, for creating a new folder for each solution, update OutDir parameter with this code:
The Build Will automatically copy OutDir content to the DropLocation folder. Have Fun