MSBuild + Team Build 2008 Presentation

You can download MSBuild & Team Build 2008 presentation.

TFS Check-In Validation Tool

New tool was released on CodePlex called TFS Check-in Validation Tool.

This tool provides the ability to have a checkin validating by a build prior to being checked in.  This is similar to a feature in TFS 2010 called Gated Checkin, which is integrated into VS and TFS (more info in this video). With both of these the goal is to prevent build breaks from being checked in by validating them beforehand.

If you really like it and are interested in doing something similar with TFS 2008 (before TFS 2010) comes out, you can check out this new project on CodePlex: http://www.codeplex.com/BuddyBuild.

It is not a part of TFS and the implementation is unrelated to the TFS 2010 Gated checkin feature.

image

<TestContainer> Works With WebTest & LoadTest In Team Build 2008 With SP1

The new <TestContainer> item in Team Build 2008 in a great way to run tests without test metadata file (*.vsmdi).

You can specify the following to run all unit tests found in assemblies matching the pattern *.Tests.dll and even specify .LoadTest and .WebTest files as well:

<ItemGroup>
  <TestContainer Include="$(Outdir)*.Tests.dll" />
  <TestContainer Include="$(Outdir)WebTest1.webtest" />
  <TestContainer Include="$(Outdir)LoadTest1.loadtest" />
</ItemGroup>

But if you try to run it in Team Build 2008, you will get an error like: Could not load file or assembly.

That’s because the task tries to do an Assembly.LoadFrom() on whatever files you include in the <TestContainer> item. This obviously fails because .LoadTest and .WebTest are XML files, not assemblies.

This problem has been solved in TFS 2008 SP1. All you need to do is to apply the TFS SP1 patch to the build machine (If you don’t want, it’s not necessary to install TFS SP1 on TF Server to get the fix).

Team Build and ClickOnce

The other day I got a question: How can I deploy an app via ClickOnce using Team Build?

There is not out of box way to do that, but we can do it with a simple workaround:

we should overload the target AfterCompile in TFSBuild.Proj to call MSBuild Task Publish and can pass the PublishDir property:

<Target Name="AfterCompile">
  <MSBuild
  Condition=" '@(SolutionToBuild)'!='' "
  Projects="@(SolutionToBuild)"
  Properties="Configuration=%(ConfigurationToBuild.FlavorToBuild);
    Platform=%(ConfigurationToBuild.PlatformToBuild);
    SkipInvalidConfigurations=true;
    VCBuildOverride=$(MSBuildProjectDirectory)TFSBuild.vsprops;
    FxCopDir=$(FxCopDir);OutDir=$(OutDir);
    PublishDir=$(OutDir);
    ReferencePath=$(ReferencePath);
    TeamBuildConstants=$(TeamBuildConstants);
    $(CodeAnalysisOption);PublishDir=\qa1SrvdropspublishedVers "
  Targets="Publish" />
</Target>

Configure Team Foundation Build for an Incremental Build

A question I got today: “How can I configure my Team Build for an incremental build?”.

So, it’s simple.

Team Build 2005

Add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.

Set the following properties:

   <PropertyGroup>      <SkipClean>true</SkipClean>      <SkipInitializeWorkspace>true</SkipInitializeWorkspace>      <ForceGet>false</ForceGet>   </PropertyGroup>

Team Build 2008

Set IncrementalBuild property to true. To do it, add the PropertyGroup definition to the end of the TFSBuild.proj file, before the closing </project> tag.

   <PropertyGroup>      <IncrementalBuild>true</IncrementalBuild>   </PropertyGroup>

Source – msdn:

Team Build 2005: http://msdn.microsoft.com/en-us/library/aa833876(VS.80).aspx

Team Build 2008: http://msdn.microsoft.com/en-us/library/aa833876.aspx

How To Deploy Data Dude Project Changes using Team Foundation Build

When you want to build and deploy database projects with team build you need to edit the database project file and the Team Build file. That’s because database projects store any non-default values for the TargetDatabase, TargetConnectionString, and DefaultDataPath properties in a <ProjectName>.dbproj.user file.  *.user files are not checked into version control in order to let every user use different values.

 

Step 1 – Modify build project file (team build .proj file)

Open the BuildDefinition.proj file, and at the bottom of the file, between the </ItemGroup> element and the </Project> element, add the following:

<Target Name="AfterDropBuild">
<MSBuild Projects="$(SolutionRoot)SolutionNameProjectNameProjectName.dbproj"
Properties="Configuration=Default;OutDir=$(SolutionRoot)..binariesDefault" Targets="Deploy" />
</Target>

 

Step 2 – modify the database project file

The target connection and database are stored in the ProjectName.dbproj.user file, which is user specific and not typically checked in to version control. You require those settings to deploy your database. Therefore, you must modify the ProjectName.dbproj file manually to specify the target connection and database.

Copy the lines that contain the definitions for the TargetDatabase and TargetConnectionString properties from the section in the ProjectName.dbproj.user file for the configuration that you want to build. These lines will resemble the following:

<TargetDatabase>MyTargetDatabaseName</TargetDatabase>
<TargetConnectionString>Data Source=ServerNameInstanceName;Integrated Security=True;Pooling=False</TargetConnectionString>

If TargetDatabase and TargetConnectionString already contain empty elements, you should overwrite those entries.

 

More into at the msdn page.

How To: Delete Build Agent In TFS 2008

I’m working on my TechEd demos which includes DB Projs and MSBuild + Team Build .I needed to remove one of my build agents.

To remove a build agent, navigate to to the Build Menu,  or the Build Explorer.  Click on Manage Build Agents in order to remove/edit/add a build agent.

BuildAgent

In order to use the Build Menu, you must first open the Team Explorer. Otherwise, the Manage Build Agents will not be part of the menu.

BuildAgent

%d bloggers like this: