I need to build a project that is not supported by MSBuild

by Donovan Brown 16. July 2011 00:48

Problem

My solution contains a .vdproj and it is not supported by MSBuild.

Solution

Call devenv from team build using InvokeProcess for .vdproj projects.

Explanation

This customization can be extended to build any project types not supported by MSBuild (vb6, power builder, fortran, VC++ 6, etc).  Any project that can be built from the command line can also be built using TFS 2010 Build using this technique.

We are simply going to add a switch statement that uses the extension of the project to determine if we pass it to MSBuild or perform the build ourselves.  Let’s start by opening DefaultTemplate.xaml from the BuildProcessTemplates folder.  To begin we must locate the correct area of the build template to add our switch statement.  I find the quickest way to do this is to click the Collapse All button at the top of the workflow designer window.  Now double click on the words Double-click to vew on all of the following activities:

1.    Run On Agent
2.    Try Compile, Test, and Associate Changesets and Work Items
3.    Sequence
4.    Compile, Test, and Associate Changesets and Work Items
5.    Try Compile and Test
6.    Compile and Test
7.    For Each Configuration in BuildSettings.PlatformConfigurations
8.    Compile and Test for Configuration
9.    If BuildSettings.HasProjectsToBuild
10.    For Each Project in BuildSettings.ProjectsToBuild
11.    Try to Compile the Project
12.    Compile the Project


The Compile the Project Sequence contains the Convert Server Path to Local Path and Run MSBuild for Project activities.  We are going to add our switch around Run MSBuild for Project.  In the toolbox expand the Control Flow tab and drag and drop the Switch<T> activity right above the Run MSBuild for Project activity.  When prompted for type, select String and click OK.

Our switch is going to test the extension of the current project being built. If the extension is .vdproj we are going to call devenv ourselves to build the setup project.  If the extension is anything else we are going to simply let MSBuild build it.  So the first thing we need to do is find the extension of the project being built.  The Convert Server Path to Local Path activity stores the project path in localProject which we can use to find the extension.  Click the double down arrows in the title bar of the Switch<String> activity to show the expression and cases of the switch.  In the Expression text box enter the following:

(New System.IO.FileInfo(localProject)).Extension.ToLower()

This line of code uses an instance of the FileInfo class to gain access to the extension of the current project being built.  We call ToLower to make sure the case of the extension is known for our comparison.

Now click the word Default to display the activity area of that case.  Drag the Run MSBuild for Project into the default case.

At this point the template works exactly as it did before we touched it. After our customizations you will still be able use this template for all your current builds that use the default template.

Now it is time to add the case for the .vdproj projects. Click the words Add new case. In the Case Value combo box type .vdproj without ”’s.  The switch already knows that what you are going to type is a string so you DONOT type the “’s.  If you do it will fail because “.vdproj” is not equal to .vdproj.

From the toolbox drag and drop a Sequence activity from the Control Flow tab onto the .vdproj case.  Change the display of this sequence to Build Setup Project.  We add a sequence here so that we can use multiple activities. Click the double down arrows in the title bar of the sequence to show it's contents.  This is where we are going to add the activities needed to build the setup projects.

Before we can add the InvokeProcess activity to build the setup projects we first need to know the command line.  Below is an example of the command line to build a setup project.  Notice we must provide the configuration to build

"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv" "C:\Builds\1\Build Sandbox\HelloWorld\Sources\HelloWorld\Setup\Setup.vdproj" /build Release

Now we can add the InvokeProcess activity and set the properties to build this command line during the build.  To get started simply drag and drop the InvokeProcess activity from the Team Foundation Build Activities tab into the Build Setup Project sequence.  With the InvokeProcess activity selected set the following values in the properties window:

•    Arguments - """" + localProject + """ /build " + platformConfiguration.Configuration
•    FileName - """C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv"""

The rest of the values can remain with their default values.  Pay close attention to the number of “’s and white space.  Because localProject may contain spaces we must quote the string. The same is true for the path to devenv.exe.

 
Whenever I use an InvokeProcess activity I always expand it and add a WriteBuildMessage under Handle Standard Output with the Message set to stdOutput and a WriteBuildError under Handle Error Output with the Message set to errOutput.  This will allow that information to be show in the build output.

 
At this point if we check in our changes and add our .vdproj file as an Items to Build from the Process tab of the build definition the setup project will be built.  Be sure and remove the .vdproj project from the solution or you will continue to get errors from MSBuild.

However, it will not be in our drop location.  The reason for this is because only items that are in the binaries folder get copied to the drop location.  The final piece is to add a CopyDirectory activity under the InvokeProcess to copy the contents of the output folder of the setup project to the binaries folder. With the CopyDirectory activity selected set the following values in the properties window:

•    Destination - BinariesDirectory
•    Source - (New System.IO.FileInfo(localProject)).DirectoryName + "\" + platformConfiguration.Configuration + "\"

Your Build Setup Project sequence should look like this:

 
Now save your xaml file, check in your changes and queue a new build.

You can download a copy of the final file below.

TFS2010 DefaultTemplate.xaml (59.14 kb)

TFS2012 DefaultTemplate.11.1.xaml (81.14 kb)

Tags: , , , , ,

Work

One lab machine will not connect to test controller!

by Donovan Brown 23. June 2011 06:28

Problem

I have a lab environment configured with 4 machines. It is running in Network Isolation, and has workflow and test capability enabled.  The testing capability fails only on one machine. 

Solution

Adjust the binding order of your network adapters so that external adapter is first.  To do this bring up the Network Connections window and click on the Advanced menu.  If the Advanced menu is not showing press the Alt key to display it.

From the Advanced Menu selected Advanced Settings.  The Advanced Setting dialog will open.

Use this dialog to move the external network adapter to the top of the list.

Explanation

If you are getting a message like the one below:

"The machine is not ready to run tests because of the following error: Unable to connect to the controller on '<TestControllerFQDN>:6901'. Reason: No such host is known. Make sure the test controller is online and the firewall on the test controller is not blocking the connection."

The chances are if you try to ping the Test Controller machine from the lab machine it will fail.  If the internal network adapter binds first it may cause issues when trying to resolve network names.  Simply move the external network adapter to the first position.

Tags: ,

Work

I can't run VMM and I am an admin

by Donovan Brown 15. June 2011 17:52

Problem

When I run VMM I am given the error I don't have permissions to run VMM on localhost.

Solution

You have to have a current VMM administrator to add you to the Administrator role in VMM under Administration tab.

  1. Start VMM
  2. Click the Administration tab
  3. Select User Roles
  4. Double Click Administrator under Profile Type
  5. Click the Members tab
  6. Click Add… and add the user

Tags: , ,

Work

I need to attach files larger than 4KB to my work items in TFS 2010

by Donovan Brown 20. May 2011 17:50

Problem

I need to attach files to work items that are larger than 4KB on TFS 2010.

Solution

Use the web services on the Application Tier to increase the attachment size.

Explanation

The default value of work item attachments is 4KB.  However, that limit can be adjusted up to 2GB if required.  To update the value you must be a TFS Admin and on the TFS Application tier to perform this process.

Open IIS Manager and expand <Server>\Sites\Team Foundation Server\tfs\_tfs_resources\WorkItemTracking\v1.0If using Server 2008 switch to Content View to see the webservices.  Right click on ConfigurationSettingsService.asmx and select Browse.

The trick to making this work is to replace “_tfs_resources” with the collection name. 

After you replace “_tfs_resources” with your collection name press Enter to reload the page.  Now you can use the SetMaxAttachmentSize method to increase the file size.

Tags: , , ,

Work

Command line tool for Work Item Queries

by Donovan Brown 16. May 2011 18:10

Problem

I need to script my work item query administation.

Solution

Use the Work Item Query Administration tool from CodePlex http://wiqadmin.codeplex.com/

Examples

This will list out all the queries and the paths you need to export them

wiqadmin list /collection:http://MytfsUrl:8080/tfs/defaultcollection /p:MyProject /recursive

This is how you can export one once you know the path. Make sure you use “ on the path

wiqadmin export /collection:http://MytfsUrl:8080/tfs/defaultcollection /p:MyProject /n:"Team Queries/Iteration 1/Active Bugs" /f:bugs.wiql

Tags: , ,

Work

Full Text Error when using Search Work Items for TFS 2010 plugin

by Donovan Brown 9. March 2011 19:38

Problem

Every time I run the Search Work Items for TFS 2010 plugin I get the following TF248015 error:

Solution

Add the account running the SQL Full-text Filter Daemon Launcher (MSSQLSERVER) service to the SQLServerFDHostUser$instance_name$MSSQLSERVER group (via computer management console) and restarting SQL Server service.

Tags: ,

Where do I place pre-conditions for test cases in MTM

by Donovan Brown 25. September 2010 02:49

Problem:

I have preconditions for a test case in Microsoft Test Manager (MTM) but I don’t know where to store or how to notify the tester before executing the test.

Solution:

Attach a preconditions document to the first step of your test case or create the preconditions as a shared step.

Explanation:

When creating a Test Case in MTM you can have attachments on each test step in a test case.  One solution to the problem of preconditions is to attach a document that contains the preconditions to the first step of your test case.  Now when the tester begins the test case the first step will be presented with a link to the preconditions document.  From there the tester can simply click the link to open the document and perform the necessary preconditions for the test case.

This same method can be used for any post conditions as well be attaching a document to the final step of the test case.

Another option is to create the preconditions as shared steps and include them as the first step in the test case.

Tags: , ,

Work

How I learned WF 4.0 for Team Build

by Donovan Brown 11. September 2010 21:17

Problem:

I have to customize a TFS2010 Build and I don't know Windows Workflow 4.0.

Solution:

I watched the following video to quickly bring me up to speed on Windows Workflow 4.0 and then I read the workflow of the default build template.

http://msmvps.com/blogs/theproblemsolver/archive/2009/12/08/online-wf4-presentation-recordings.aspx

Tags: , ,

Work

How to deploy a Database Project with Team Build 2010

by Donovan Brown 6. September 2010 19:17

Problem:

I need to deploy a database project during a Team Build.

Solution:

Edit the dbproj file to include the Deploy target.

Explanation:

  1. Open the solution that contains the desired database project. 
  2. Right click on the database project and select properties. 
  3. Click the Deploy tab and verify the Deploy Action is set to "Create a deployment script (.sql) and deploy to the database, and the Target Database Settings are correct. 
  4. Now we need to update the .dbproj file to include the Deploy target.  From the Solution Explorer right click the database project and select "Unload Project". 
  5. Right click on the database project and select "Edit [database].dbproj" where [database] equals the name of your database project. This will open the .dbproj with an XML editor. 
  6. Update the DefaultTargets attribute of the Project element to "Build;Deploy". 
  7. Save and close the file then right click the database project and select "Reload Project". 
  8. Check in your database project.
  9. Queue your build. Your database will be built and deployed.

Tags: , ,

Verify SharePoint 2010 Products for Team Foundation Server

by Donovan Brown 24. August 2010 22:19

Problem:

You have to install TFS2010 on an existing Sharepoint2010 install.  How do I verify it is configured correctly?

Solution:

I have been handed many preinstalled SharePoint 2010 machines to use with TFS installs or upgrades. The problem is there are many options that must be just right for it to work with TFS and confirming those settings can be very difficult if you don’t use SharePoint very often.  For example the two I constantly have to verify are that the web application on port 80 has NTLM set for IIS Authentication and the Anonymous Access is disabled. 
Here are the steps to confirm this information. 
1. Open Central Administration
2. Click Manage web applications under the Application Management section
3. Select the desired Web Application
4. Click the Authentication Providers button
5. On the Authentication Providers Pop Up click the Default link
6. You can now edit the authentication settings and confirm that NTLM is selected and Anonymous Access is disabled.

Tags: , ,

Work

About the author

My name is Donovan Brown and I am a process consultant for Imaginet with a background in application development.  I also run one of the Nation’s fastest growing online registration sites for motorsports events DLBRacing.com.  When I am not writing software I race cars for fun.  DLBRacing.com has given me the opportunity to combine my two passions writing software and racing cars.

AdSense

Month List

AdSense