Hack the Build: Programmatically Converting Older VS .NET Projects to MSBuild

Jomo Fisher--There are plenty of reasons you might want to programmatically convert projects from VS .NET 2003 format to MSBuild format. Maybe you have a bunch of old .csproj files and you'd like to convert them in batch. Maybe you'd like to keep your projects in VS7 format and convert them to MSBuild format on the fly. These are definitely Hack-the-Build-worthy pursuits, so let's dig in.


MSBuild ships with an assembly called Microsoft.Build.Conversion.dll which contains the code that Visual Studio .NET 2005 uses to convert older C# and VB projects into MSBuild format (unfortunately C++ is not supported).


The code for calling this API is so simple, I can paste it right here:



Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

Written by Jomo Fisher



using System;

using System.Text;

using Microsoft.Build.Conversion;


class ConvertProject


     static void Main(string[] args)


          ProjectFileConverter c =

           new ProjectFileConverter();

          c.OldProjectFile = args[0];

          c.NewProjectFile = args[1];






To invoke, just call the code with source and destination file names:


   ConvertProject VS7.csproj VS8.csproj


A few things to note:

·        You'll need to add a reference to Microsoft.Build.Conversion in your project.

·        You'll need to manually copy the DLL Microsoft.Build.Conversion.dll into the same directory as the application built from the code above. Chances are that we'll have this DLL in the GAC for the next Beta, but for now you'll just need to manually copy it.

·        This API is undocumented and not supported for calling directly. Caveat emptor, etc.


If you subscribe to other Microsoft Visual Studio related blogs you may have noticed a lull in the postings. This is because we're working like caffeinated woodpeckers getting the next Beta of VS ready. Thankfully, the tryptophan has cut through my (legal) stimulant haze long enough this morning to allow me to post a hack for you—I hope you find it worthy.


One thing worth mentioning as we head down the homestretch: We've used Test Driven Development with NUnit throughout most of the MSBuild development cycle. We're really seeing a big pay-off in the end-game--we're able to make difficult changes in complex code with confidence that we're not breaking functionality. In other words, I've tasted the Kool-Aid and can only say “Oh, Yeaahh!”.


This posting is provided "AS IS" with no warranties, and confers no rights.


Comments (14)

  1. Since you mentioned it, could you talk a little about how you use NUnit to test. My company is looking into changing some of our methodologies and TDD has come up as the last best hope ;-). If not I’ll understand, but I just think a lot of people are interested in how MSFT does the things it does.

  2. Lorenzo says:

    Great! It seem to be the right way to resolve my problems. Today I’ll try to code it into my project. Thank you Jomo!

  3. Leo Duran says:

    This little tip saved me a helluva lot of work! Thank you!

  4. Jomo Fisher–I mentioned a while ago that MSBuild team uses Test Driven Development (TDD). Afterwards,…

  5. I don’t think of Test Driven Development as just a goal in itself. I think of it as a platform for a set of code-quality drivers. What follows is a set of ideas for how to wring the maximum use out of your developer-written tests.

  6. The following links to .NET resources have been collated over time with the assistance of colleagues.&amp;nbsp;…

  7. Kyle Finley says:

    I know this post is a litle old but hopefully someone is watching it.

    Is there any way to go backwards?  from a VS8 format to a VS7?  I have a funky requirement where we need to do this.

    Any ideas?

  8. I know this post is a litle old but hopefully someone is watching it.

    I do not agree. Go to http://www.hotelsclub.info/swag_Spain/cue_Castilla%20y%20Le%C3%B3n/dissimilate_Burgos_1.html

  9. I know this post is a litle old but hopefully someone is watching it.

    I do not agree. Go to http://www.frhotelweb.info/invoke_Italy/garner_Lazio/indirect_Rome_1.html

  10. I know this post is a litle old but hopefully someone is watching it.

    I do not agree. Go to http://www.autosjobs.info

  11. I know this post is a litle old but hopefully someone is watching it.

    I do not agree. Go to http://www.cybercareers.info/imbecile_Germany/presence_Niedersachsen/floreated_Hannover_1.html

Skip to main content