Visual Studio-My favourite extensions

I spend my life working in Microsoft Visual Studio – and that’s no exaggeration. I work in it pretty much all day (day job => developer, kinda obvious), but then I also spend a fair bit of time outside of work doing development – be it for friends / family, but more so these days as the freelance developer that I still try and keep going.

Now, I’ve been working with Visual Studio since the early days of .NET framework – so that's back to 2003 (so 2002 release I think?), and over that time I’ve tried lots of different extensions – some good, some very bad.

These days I’m using:

Telerik JustCode [Website] [My thoughts]
A refactoring, code stat, cleanup and all round absolutely “can not do without” tool. I love this tool, and I have to say, it’s one I don’t object to paying for.

VSCommands [Website]
I look at this as basically what Microsoft should include in Visual Studio, but don’t. Another un-grudged paid for extension.

Most real-users of Visual Studio will have encountered this one now. I’m not a MASSIVE fan, but really, you can’t get away without it with some projects these days. Personally think it will just be another tool that ends up being a mess …

Python Tools for Visual Studio [Website]
I’ve been (un)lucky to have been required to do a fair amount of Python work in the last year, and I found this plugin while I was (ironically) finishing the particular project. And it made my life so much easier – working in familiar IDE doesn’t half help your productivity!

There are also a few “external” tools that I use rather often (yes, I do use OTHER PEOPLES tools instead of just re-inventing the wheel all the time!!)

CleanProject [Website]
A small tool to strip all the crap out from Visual Studio project directories – perfect for when you need to email it or slam it into DropBox etc.

XAML Binding-Design time tip

One of the things that I always see new Silverlight / WPF (and now Windows Mobile!) developers struggle with is control binding – more specifically, I see them putting values in while designing a screen then swap them out for the actual binding before compiling.

However, there is an easier way.

Bindings have an additional property called FallbackValue – which will be rendered in design view too.

So, instead of:

Text="{Binding Visitors}"


Text="{Binding Visitors, FallbackValue=0}"

At least its one less thing to remember to swap out!

Telerik JustCode

For a while now I have been using the Telerik JustCode Visual Studio extension tooling which provides extended Code analysis and Refactoring capabilities – something that I find the standard environment has significant faults in.

I actually started off using Resharper to extend Visual Studio, and was using it for many years before JustCode was around however I found myself switching due to a number of reasons:
- Poor performance
- JavaScript refactoring
- Extensions to Unit Tests (new unit test runner)

It also helps that the Telerik team are extremely receptive to wish list feedback, and in fact, seem to release builds just when I’m wanting new features Smile

So, what exactly is JustCode?

Well simply put its a plugin for Visual Studio 2005, 2008 and 2010.
What does it provide? Now that’s a fairly long list:
- Code Analysis
- Refactoring
- Unit Test extensions
- Code Templates
- Code Navigation and Search
- Code Assistance
- Code Generation
- Code Quick Fixes
- Code Cleaning and Formatting
- Code Quick Hints

I could go on forever and give you a full rundown on the functionality in detail, but I’m not going to. Instead, if you are interesting, why not read the Telerik JustCode page? It covers everything.

What are the benefits? Ultimately, I code quicker – and more efficiently. Common errors such as locating missing classes in assemblies that you do not reference (yet), removal of duplicate or unnecessary characters, automatically adding casts  and more.
The much improved error display is also a god send – and seems to be more accurate that the one in Visual Studio too (it’s actually part of the Code Analysis part of JustCode). It has support for C#, Javascript, ASPX and XAML – basically all the languages that a modern .NET developer has to be conversant in!

But, my absolute favourite has to be the extensive refactoring tooling; being able to move types to new class files, extracting methods to improve code reuse and automatically adding relevant stubs in descendants. Lots of little operations that I know we can all do manually, but why should we? Surely tooling such as this can only make us faster at producing quality code?

As it stands, JustCode is only one of a couple of tools that I always install in my Visual Studio environment to allow me to shape it to my needs – but more on the others some other time!

For now you homework is to go and check out JustCode, and see if it will help you code faster …

Azure and the 'Aborted' / 'Recycling' Role

I recently uploaded new, very basic, template project into Azure as the basis of something I’m working on, and after the pre-requisite eternity waiting for it to initialise realised that it was cycling between Aborted and Recycling states. Very odd.

So I tried again. Same thing.

I gave up and contact support.

I have to say, they were quick dealing with the request, but the information they gave was … to say the best … rather annoying.

The problem was I used MVC3 they said, and the DLL’s weren't included.

Fair enough.


BUT, surely the Azure packaging tooling should be more intelligent? If Microsoft’s own libraries are not preloaded on the platform (only .NET 4 is from what the engineer said), then surely the packaging tool should identify references that are not present and either warn or include them. Not just carry on happily.

Not only that, the information should be exported to the NEW azure portal, not hidden away. I’m told the information is available via RDP login (which has to be enabled … yes you guessed it … in the configuration when you deploy – so yet another delay!), but surely thats overkill for most web roles?

Team Foundation Server 2010-Process Template Editor

I can almost guarantee that if you use TFS, you will need to edit a process template sooner or later; the default forms that TFS provides, although good, always need tweaked to fit how your team works.

I even find the EMC Scrum pack needs tweaked at times (I mean, why is there no assigned to for a bug??).

So, the easiest way to do this is to ensure you have the Team Foundation Power Tools installed, fire up Visual Studio them click Tools, and select Process Editor – then you get to choose what you want to edit!


The most common one I end up editing are Work Item Types – and specifically, I tend to cheat and edit them through this tool on the server.

Now, be sure to abide by all the warnings when editing process templates. These changes kick in immediately, and effect EVERYONE on the dev team using this project. You have been warned.

Also remember to export any modifications and re-import them on other project collections that use the same template for consistency.

Team Foundation Server-E-Mail Alerts

I love things that remind me to do things. I’m a forgetful person, and I need prompts. So I guess that's why I’m a big fan of e-mail alerts, and one of the first things I do in TFS is configure them.

The only annoyance I’ve ever hit with TFS alerts is the rather strange absence of ability to setup the authentication for the SMTP server used for the alerts – I like to use an external server, as for a lot of the jobs I’m involved in, the users are very widely geographically dispersed, and all on different providers.

While you can correct this shortcoming by editing the TFS web services config file (found at C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\Web Services\web.config), I don’t like this approach, as I feel that it is risky – you never know if something will overwrite this file, especially a service pack etc.

So, what do you do?

Simple, install the SMTP Server Feature of IIS on the server, and run a locally restricted SMTP Service that redirects to your smart host.


Once you have installed the SMTP Server, its important that you secure it – ideally you want to set the only machine granted relay permissions as the local machine ( Then go to the delivery tab, and click Advanced. Specify the details of your external smart host – if you need to provide authentication, you will find the relevant options under the Outbound Security button.

Then, open up Team Foundation Server Administration Console, click on Application Tier, and then Alert Settings (over on the right). Fill in the boxes, and away you go.


Oh, and one last thing – make sure the SMTP Service is running!

The final step is to use the excellent Alerts Explorer tool that is in the TFS PowerTools pack to setup your alerts.


Team Foundation Server-Automated Backups

One of the things that never ceases to make me smile is the number of companies running Microsoft’s Team Foundation Server software … who don’t back it up.

For those that don’t know, TFS can be looked at as a central store for pretty much all the work that goes on inside a software company. Neglecting to back it up is opening yourself to disaster.

As the TFS Databases are nothing more than SQL Databases, you can back them up in the normal SQL way, or use a tool (there are multiple databases, and you have to get them all at the same time and in the same state – not always easy to achieve). My favourite tool of choice for handling these backups is actually part of the Microsoft Team Foundation Server PowerTools, and integrates neatly into the TFS Administration Console.

The first step after installing the tools is to Create Your Backup Plan.


Some things that you will need before you start are:

* A network location where you want your backups to go
* An idea how long you want your backup retention (defaults to 30 days)
* An idea of how you want to schedule your backups – the default nightly runs at 2am local time

Now, my TFS Server doubles up as the main fileserver, so I cheated and entered a local path in the Network Backup Path. (These in turn are synced off to a remote device nightly). This, although being accepted, failed the Readiness check – as its not a network path.

One strange gotcha, I chose to run Full and Transactional backups – leaving Differential off, and you have to uncheck any checked day selection boxes before you can continue.

The other thing that caught me out was the Grant Backup Permissions and Backup Tasks Verification steps were failing, saying that my own account did not have suitable rights for the backup location (strange, as I’m an Admin, and I have full writes to both the NTFS folder and the share). After checking the TFS and SQL Server logs, it was a problem that my target share had a space in it. Putting quotes round it doesn't help either, just causes something else to fail.

And the third, and final thing? Don’t use Local_System account. Remember to setup your own, restricted where possible, account for all services.


Mvc Scaffolding - Part two

I need to start tonight's blog post with an apology … in last nights post, I neglected to explain what NuGet is – I kind of took it for granted that you developers out there would know.

NuGet is a Microsoft spin off that is intended to make the introduction of new developer frameworks to Visual Studio and your projects easier – removing the need for you to remember all the assembly dependencies. All you do is open the Package Manager Console (View, Other Windows, Package Manager Console) and key in a few PowerShell commands – and NuGet will pull down the dependencies onto your machine, and update your open project. Simples.

So, lets get rocking. We have our sample project (MVC 3 Razor) up and running. For this sample we are going to build a very simple prototype around an order, and the information it would hold.

We need the following classes:


public class Address
    public Guid AddressID { get; set; }

    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    public string AddressLine3 { get; set; }
    public string City { get; set; }
    public string County { get; set; }
    public string PostCode { get; set; }
    public string Country { get; set; }


public class OrderItem
    public Guid OrderItemID { get; set; }

    public int Quantity { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }


public class Order
    public Guid OrderID { get; set; }

    public Address DeliveryAddress { get; set; }
    public Address InvoiceAddress { get; set; }

    public DateTime OrderDatae { get; set; }

    public List<OrderItem> OrderItems { get; set; }

You’ll probably notice the [Key] decoration in that lot – these define key indexes, which Entity Framework Code First needs to setup the necessary indexes for CRUD operations on the database. You will need to add a using statement to each of your class files for the namespace of System.ComponentModel.DataAnnotations.

So – that defines an order which has two address (one for the delivery and one for the invoices), and a list of items.

Lets go ahead and create a controller, and the CRUD pages for the Order. Open up Package Manager Console, and type in

scaffold controller Order

You will see that the MvcScaffolding framework gets busy and creates the relevant update pages – but most importantly it creates a Context, also within the Models folder. In this example its called ScaffoldingExampleContext.cs. This brings us to the first couple of annoyances with Scaffolding, and EFCodeFirst.

- The database context gets placed in the same project – no easy separation here to give you a distinct data access layer.

- The context connection string expects you to have SQLExpress installed, and operating as a named instance of “SQLExpress”.

On my machines, the latter is not the case, so we need to pop into web.config and add a ConnectionString into the configuration block:

  <add name="ScaffoldingExampleContext" connectionString="data source=.;Integrated Security=SSPI;Database=ExampleData" providerName="System.Data.SqlClient"/>

Fire up your project, and got to /Orders/ on the site that launches – you will be presented with a very simple CRUD interface for the Orders.

You would need to run the same Mvc Scaffolding command (scaffold controller <classname>) against each of the classes, and then you have a little but of manual plumbing to do – such as navigation, and in this case, the actual selection of things like Address and Items.

Scaffolding, at this time, can not handle complex objects such as other classes or list definitions to give you a total coverage CRUD interface, but it can generate most of the simple stuff that makes up a lot of the work involved in most prototypes.


Mvc Scaffolding - Part one

I love learning new things connected to software development – and anything that has the potential to save me time is always high up on the list of things to investigate. After all, time is money – either for yourself when you are a contractor, or your employer if you are an employee!

I’m sure you all have been using MVC (Model View Controller) structures for a while now, but I’ve only recently started looking at the “Scaffolding” approaches that are out there – these are quick, simple ways of building, essentially, your prototype application based only on the base models. So you create one class, and the Scaffolding framework builds the views, and the controller for you. Job done. Oh, and it also sorts out the persistence (read: database) for your models too.

Sound like its too good to be true?

Well, I’m not going to say its perfect, in fact, it seems to have some insanely annoying “defaults” – some of which I’m going to introduce you to while we go through this introduction to Scaffolding over the next few days / posts.

First off we need to install the scaffolding stuff – the easiest way to do this is to use NuGet in Visual Studio 2010.

Create a new MVC 3 Razor project (my preference!).

Open up the Package Manager Console, and type in:

Install-package mvcscaffolding

Sit back and wait while the packages are installed. A reference to the scaffolding libraries will be added to your project automatically.

Now, I’ll go into actually using the scaffolding library in my next post, but first, I want to bring your attention to, what in my opinion, is one of the most annoying things about this library.

It uses Entity Framework Code First (EF Code First). Basically this is a wrapper for Entity Framework that lets you write your models and have it handle the generation of the database schema around Entity Framework. So far so good. But it looks for an instance of SQLExpress. Total pain in the ass in my case, as I don’t have it installed as “SQLExpress” … so it fails out of the box. Wonderful.  There isn’t a nice way that I’ve found to change this across the board, so you are down to changing it per project. Again, I’ll cover this on my next post, as you really need to have at least one Model “scaffolded” first so you know what context names etc will be used.

TFS 2010: Using a 'hard lock' approach to source control

Just in case anyone is a TFS 2010 user, and they don’t like the multiple checkout support that it has (i.e. more than one person can edit the same file, and they just have to resolve conflicts on check in) then you can change it to use the old-school approach of full locking on checkout – this means that only one person can edit a file, or even, hold a lock on it. If anyone else wants to edit that file, they are blocked until you check in your changes.

Why would you do this? Well, pretty much the only reason is if you have developers on your team who don’t understand “current” source control and you keep loosing changes when people check in.

So, how do you change this option? It’s easy enough, but you will need permissions on the Team Project to change it – if you are unsure, speak to your TFS Administrator.
To get to the option itself, first go into Visual Studio, to the Team Explorer and then right click on the project you want to change the option for. Then select Team Project Settings, then select Source Control.
In the dialog that appears, untick “Enable multiple check-out” and hit ok.

Job done.