<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).

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.

ALM 403: Control Your Database Lifecycle With Data Dude – Agenda

Next week I’ll give a session at TechEd 2008 In Eilat, Israel. The session will introduce you how you can control your database changes and integrate it into your agile development methodology.

Do you want to control your database changes?

Do you want to test your database with unit test and even run static analysis on it?

Do you want better life and easier deployment of database schema changes to production database?

If one of your answers is YES, come to hear me.

Session Details:

  • Session Name: ALM403: Control your Database Lifecycle with Data Dude
  • Level: 400
  • Time: 8/4/2008, 9:00 AM
  • Location: Hilton Hotel, Ofir-Adom Hall

Session’s Agenda:

  • What is Data Dude?
  • Data Dude Features
  • Test Your Database!
  • Build & Deploy (MSBuild & Team Build)
  • Case Study: nuconomy
  • Q & A
  • Summary

Microsoft opened up the meetings application at http://www.face2facemeeting.com/teched/. If you want to meet me and talk with me on development, WCF, LINQ, ALM or anything else – contact me! I’ll be glad to see you!

Meet you there…

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

Remove Items From ItemGroups In MSBuild

The ability to remove entries from ItemGroups is one of the new features of MSBuild 3.5.

To remove an Item from an ItemGroup in MSBuild 2.0 you would have to create a new ItemGroup from the old one and skip the Item that you needed removed.

In MSBuild 3.5 we can achieve it by using the Remove parameter.

Example:

<ItemGroup>    <Files Include="a.cs" />    <Files Include="b.cs" />    <Files Include="c.cs" />    <Files Include="d.cs" />    <Files Include="e.cs" />    <Files Include="f.cs" />    <Files Include="g.cs" /></ItemGroup>

Some times we want to restrict some data from this group in a target. In order to do it,  we should use the Remove parameter:

<ItemGroup>    <Files Remove="a.cs" />    <Files Remove="e.cs" />    <Files Remove="f.cs" /></ItemGroup>

Read more at msdn.

Running Tests On TFS Build Machine

Often I asked “What do I need to install on the TFS build machine in order to run tests?”

Well, the answer is simple.

In VSTS 2005 you have to install the Tester or Suite editions on the Build Machine to run tests (even Unit Tests).

In VSTS 2008 installing the Developer Edition version is enough.

%d bloggers like this: