Building and Unit Testing .Net 4.0 with Team Build 2008

One of the tasks this week was to install and configure a new BizTalk 2010 build server in my clients environment. Pretty straight forward you may say huh? Well it would be if my client was using TFS 2010 but in this case we’re talking about a TFS 2008.

There are lots of posts like this great post explaining how to do this and the building part worked fine. But I kept getting error telling me that unit tests where not able to run because I didn’t have the correct version of Visual Studio installed. Anyway here are the steps I followed to succeed with this endeavor:

  • Install BizTalk 2010 compilation components
  • Installed Team Build 2008
  • Installed Team Build Service Pack 1
  • Configured Team Build 2008 to use MSBuild 4.0 instead of MSBuild 3.5. To do this edit %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\TFSBuildService.exe.config and set the MSBuildPath property to C:\Windows\Microsoft.NET\Framework\v4.0.21006\
  • Restarted the Team Foundation Build service
  • Tried a simple Hello World application without unit tests and the build worked fine.
  • Added some unit tests to the Hello World application and got error the following error MSBUILD : warning : Visual Studio Team System for Software Testers or Visual Studio Team System for Software Developers is required to run tests as part of a Team Build
  • Installed Visual Studio 2010 Premium
  • Got new error telling me that there was some problem with workspace creation during build, found this solution.
  • Changed the property $(COMPUTERNAME)_$(BuildDefinitionId)_$(BuildAgentId) to $(COMPUTERNAME)_$(BuildDefinitionId) in the file %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\TFSBuildService.exe.config.
  • Got back the same old error MSBUILD : warning : Visual Studio Team System for Software Testers or Visual Studio Team System for Software Developers is required to run tests as part of a Team Build
  • Installed Visual Studio Team System 2008 Development Edition
  • Finally the build worked fine and all the unit tests ran successfully!

Hope this will summarize some of the issues you might run into when trying to build and unit test .Net 4.0 applications with Team Build 2008.



Creating a bootable VHD the easy way…continued

You might have read and tried the scripts from my first blog about creating a bootable vhd here, and in this blog post I’ll continue where I left with some information about my usage of difference discs and bootable vhd’s.

First of all I started by creating a bootable vhd with my script with the following options:

Name Type Size
Base2k8r2.vhd Expandable 80 000 Mb (Remember that you need this much free space on your disc even if the vhd doesn’t have the size from start)

This left me with a vhd-file that took about 7Gb on my internal disc. I restarted my machine to make sure that my bootable vhd was working correctly.

After the health-check and some customizations like folder options in explorer I opened up a command prompt and entered shutdown /r /f, this way I don’t have to enter a reason to restart my Windows Server 2008 R2 OS Blinkar

Back in Windows 7 I took these steps to create a difference disc to keep my base disc clean:

  1. Start a command prompt as Administrator
  2. Write BCDEDIT /v and hit enter
  3. You will see the boot entries and their GUIDs
  4. Write BCDEDIT /delete {guid to the entry with a the path to your bootable vhd}
    WARNING this will delete a boot entry, make sure you enter the GUID to the entry where the device/osdevice points the path of your bootable vhd. Entering the wrong guid could make your computer UNBOOTABLE.
  5. Write DiskPart and hit enter
  6. Enter CREATE VDISK FILE="<Path to difference vhd>" PARENT="<Path to parent vhd>"
    You must specify a valid folder name or you’ll get an error.
  7. Write SELECT VDISK FILE=”<Path to difference vhd>” and hit enter
  8. Write ATTACH VDISK and hit enter
  9. Write Exit and hit enter
  10. Write BCDBOOT <your assigned drive letter>:\Windows and hit enter
  11. If you write BCDEDIT /v and hit enter you should see a new boot entry that points to your new difference disc.
  12. Restart your machine and make sure that your bootable difference disc starts correctly.

When I get some time I’ll try to automate these steps into a handy batch-file or application. I hope you found this post interesting.



End to end TFSBuild pattern for BizTalk 2009, part 2 (Tools)

Ok, you finally got your build environment installed and tested with a simple Hello World build and you’re ready for the next phase.

Before I show you the good stuff J there is some tools that you need to succeed with this quest:

  • You’ll need basic knowledge of MSBuild and TFSBuild or you could copy and paste my build pattern if you like J
  • I mainly use the OOB tools that come with .Net framework and BizTalk i.e. BTSTask, BTSWCFServicePublishing and GacUtil with my builds because I find them to be stable, supported and generally well documented.
    These tools should already be installed in your environment but you’ll have to make sure that you have the correct permissions on your TFSBuild service account to use them.
  • I use BizTalk MsBuild Generator to start and stop BizTalk applications so you will need to download the tool and extract BizTalk.BuildGenerator.Tasks.dll and BizTalk.BuildGenerator.tasks. These two files are then placed under source control with the teambuildtype.
  • If you need automatic generation of the BizTalk binding-files from a template (for different target environment for instance) I have found the XMLPreprocess tool very helpful.
  • In the early years I used the SDC tasks but it’s no longer supported but there is still a lot of good stuff in that package if you want to learn MSBuild in more depth. The replacement is called MSBuild Extension Pack if you want to check it out. While you’re at it you should really checkout MSBuild Explorer.

Try to install the tools in a common directory i.e. C:\BuildTools or something similar and keep these tools under source control at all time.

Until next time have a good one!