Tag Archives: Visual Studio

Australian ALM Conference Wrap Up

Last week I had the pleasure of speaking at the first annual Australian ALM Conference. My talk covered a “What’s new” of Team Build as well as the customisation experience for Team Build 2010. It was really great to see a large group of people interested in Team Build and I was really excited by some of the post-session questions.

If you were interested in obtaining the slide deck, or the sample code I wrote during the session the event organisers have posted them in a zip on the Agenda page of the Australian ALM site.

If you have any questions I didn’t get to answer during/after the session feel free to contact me on stephen.godbold at gmail.com or tweet me on @SteveGodbold


Code Analysis in Team Build 2010

Code Analysis provides an executable set of rules that can be checked during a build to ensure standards and practices are being adhered to during development. This functionality is a great addition to a team build, and the tools required come as part of the Team Build Agent 2010 installation. Recently I’ve been doing some digging into how the Code Analysis is setup and triggered during a build.

Configuring Code Analysis

The first step to having code analysis run as part of your team build is to configure the rule sets and execution of analysis during the build of your project files. To do this, right click your project file and bring up the properties interface. Go to the Code Analysis tab and check the Enable Code Analysis on Build check box. This defines a constant that MSBuild will use to determine if the analysis should be run or not. You then need to pick your rule set, which can be set in two places. Firstly you can set it on the projects you want to run analysis against individually.

Project Properties

Configuring code analysis in project properties

This will get you started with Code Analysis, but once you turned on the analysis there must be a better way to get a view of the rule sets across the board for your solution right? If you right click your solution file and open up the properties interface, then click the Code Analysis Settings item you’ll see something like this:

Configuring rule sets in solution properties

Configuring rule sets in solution properties

This will give you a nice view of the code analysis rule sets for all of the projects in your solution. Something to note here is that the rule settings can be chosen on a per configuration basis. You can also use the ‘All Configurations’ option to set them across the board.

Once you’ve enabled Code Analysis and picked a rule set you should be able to run a local build and see a set of warnings shown for those rule violations that exist in your code. We’ve now got code analysis in our local build!

Code analysis warnings

Code analysis warnings in local build

Configuring Team Build to execute code analysis

Having local code analysis configured is a great place to start. Adding support for executing the code analysis in Team Build is the next step on the road to ensuring consistency in code. Setting up code analysis is really quite simple in the default build template.

First open or create the build definition you’d like to run code analysis in. Once you’ve got the Build Definition screen open, head to the Process tab. On this tab, you should see a parameter in the Basic group titled ‘Perform Code Analysis’. The default value here is to use ‘AsConfigured’ which will ensure execution for those project files that specify the code analysis constant with the rule sets defined. You can also turn it on with an ‘Always’ setting, or off with a ‘Never’ setting.

Build Definition

Configuring code analysis in your build defintion

How does code analysis get run?

There are a lot of good posts on how FxCop itself works, so I won’t cover it here. I also won’t cover writing custom rules or custom rule sets.. What I will cover is how it gets called during part of your Team Build.  My images here are based on the default template, so the activities used are all included in the standard install.

The settings for Code Analysis are passed into the executing build workflow as arguments. You can check these by opening the XAML, and clicking the ‘Arguments’ button at the bottom of the workflow designer.

Build Arguments

Build arguments on workflow designer

The list you see are the arguments defined for the workflow as a whole. If you’d like to see the arguments scoped to a specific activity, use the ‘Variables’ button next door.

If you start with a collapsed view (recommended) you’ll need to navigate down the activity tree to locate the Run MSBuild for Project activity which is an instance of the MSBuild activity. If you click this activity and open your properties window you’ll see that the activity accepts a  ‘RunCodeAnalysis’ parameter which is bound to the ‘RunCodeAnalysis’ argument specified for the build workflow.

Activity Configuration

Properties as configured for MSBuild activity

Pretty simple so far right? Time for some reflectoring to see what actually occurs here. Once we’ve loaded the Microsoft.TeamFoundation.Build.Workflow assembly into reflector we can navigate through the Activities namespace and locate the MSBuild activity. Once there we’ll a look at what exists inside. What you’ll see is pretty much what you’ve seen in the properties dialogue in Visual Studio. Lots of properties to allow the configuration of the build call. What you didn’t see in Visual Studio was the list of helper methods used inside the activity. There’s one particular method we’re interested in here which is titled ‘GetFxCopPath’.

Reflected MSBuild Activity

Content of the MsBuild activity viewed in Reflector

If we disassemble this method we’ll see that the method checks a registry key to find the FxCop executable path and returns that to the caller.

GetFxCopPath Dissasembled

GetFxCopPath Method Content

Digging a little deeper into the activity we find it utilises an internal code activity known as GetCommandLineArguments. This activity contains the following code snippet in its execute override:

GetCommandLineArgs Snippet

GetCommandLineArgs method content

This code sets up the execution of Code Analysis based on our build and project settings, and the path to the FxCop executable that was located via the registry key earlier. From here on, code analysis is run as per the normal MSBuild process based on these settings we’ve provided.

Known Issues

Unfortunately due to a bug discovered very late in the release cycle the install for Code Analysis does not execute on x64 build servers. This means you won’t see code analysis running despite correct configuration. The work around for now is to install a Visual Studio SKU that includes Code Analysis on the build machine to get the FxCop installation.


Making use of Code Analysis during a Team Build is a great way to help ensure a good level of consistency across your code base. Armed with this article, and some knowledge of how FxCop inspects code and applies rules you should now be ready to incorporate this useful tool into your automated build process.

VS2010 RC Intellisense Crash – Second Patch Available

A few weeks ago there was a patch released for a bug in Intellisense in the Visual Studio 2010 release candidate that was causing crashes. In most cases this patch resolved the issues experienced, however in a few cases a bug remained that caused Visual Studio to crash with a System.InvalidOperationException when performing QuickInfo. If you’ve installed the original patch (available here) and are still experiencing crashes when attempting to view an Intellisense prompt there is now a second patch available on connect to address the additional issue.

If you still experience issues after installing these patches make sure you log an issue on connect so that the right team is made aware of the problem.

Canberra VSTS User Group – March 2010 Meeting

March sees a slight break in schedule, with the Australian ALM conference in April we’ve decided to move the next meeting forward a month. This means our next meeting will fall on Wednesday, March 10th. The details are below:

0810 – 0830: VSTS Breakfast

Share a bite to eat with the Canberra VSTS group. Bring your VSTS queries and triumphs and share them! Quiz your peers on how they are getting the most out of VSTS, and maybe pick up some ideas you can take to work with you.

0830 – 0930 : SessionVisual Studio 2010 Tips and Tricks
Ducas Francis – Senior Consultant for Readify

Are you looking for an excuse to move to Visual Studio 2010, or do you simply want to know how to make the most out of an amazing new IDE…? Come see some of the cool new features in the latest release of VS2010 that can help you increase your productivity as a developer. You might even walk away with some insights into features you didn’t realise already existed. Just remember, ReSharper is a dirty word!

Thanks to the support of Microsoft, this month we have copies of Windows 7 Ultimate to give away! To go into the draw all you need to do is hand in your speaker evaluation form, with the winners being picked at random from the submissions.

Head here to register your attendance, and sign up here to get notified of upcoming meetings/news!

Australian ALM Conference Dates and Early Bird Offer

Australian ALM LogoThe Australian ALM conference dates have been re-announced recently, and registrations have opened.  This means now is the best time to take advantage of the early bird offer – if you’re one of the first 50 attendees to register for the conference you will receive a free NFR copy of Microsoft Expression Studio 3.0!

The conference will be held on the 13th and 14th of April at the one and only Luna Park in Sydney, Australia. It will showcase some great Australian and international speakers in two content tracks and includes the option of attending post conference training. The event will also be the official Microsoft Australia launch for Visual Studio 2010, so if you’re interested in application lifecycle management or want to get a feel for what makes up the Visual Studion 2010 offering head over the registration site and grab your ticket now!

Australian ALM Early Bird Offer

Canberra .Net User Group – VS 2010 Resource Post

The slide deck for the session including the links are available from here in my SkyDrive. Thanks to everyone who came, and I hope you’ve caught the VS2010 bug!

I must say a really big thanks to Peter Sullivan and Bud de Silva for helping me out with hardware this week. The demo was done on Peter’s laptop and external HDD and I got the CTP from Bud and had his drive as a backup in case things went south with the CTP on Peters. Cheers guys – I couldn’t have done the talk without your help!

If you liked the presentation, and would be interested in seeing it again – or if you’d like to show it to somebody else let me know and I can either try and Camtasia it (not sure about Camtasia and the CTP memory wise) or I can even give it again in person after the holiday season!

Resuming conflict resolution with TFS and Visual Studio

Have you ever cancelled out of a conflict merge dialogue only to realise shortly after that you couldn’t get it back and you needed to finish up the merge? I have. Fear not though – there is a way to get the it to reappear!

Head up to your File menu, browse to Source Control and click the ‘Resume Conflict Resolution…’ menu item. Visual Studio will re-query your conflicts and allow you to continue to resolve these issues.

Resume Conflict Resolution