Round-tripping Silverlight 3 projects with Visual Studio 2008 and Visual Studio 2010

22 October 2009

Now that Visual Studio 2010 Beta 2 is out, it is a lot of fun to use the fully interactive design surface for Silverlight. However, it comes at a cost: you need to use the conversion wizard to bring your Visual Studio 2008 solutions and projects up to the expected format for the designer tools and new build environment.

If you deliver your source ultimately to a Visual Studio 2008-targeted source project, or have issue adopting a beta product until its release, this is a pain.


I wrote a tool last month for round-trip converting Silverlight-specific solutions and .csproj files between the versions, and want to share it as-is, with no warranty, hoping someone finds it useful.

Here are two potential solutions for dealing with the conversion issue, actually the second builds from the first.

Use Source Control

If your project is not churning that often in added and removed files, source control is the easiest solution to this problem!

  • Open your solution in Visual Studio 2010
  • Allow the conversion wizard to complete
  • When checking in, carefully revert the .csproj and .sln files (assuming no changes to their contents)

Easy enough. But not crisp enough!

Use my hacky program

Now assuming you are already using source control, then you can consider using my script/tool for performing the round-trip conversion. You still want to have everything in source control – you just never know.

Before we start

  • This program will work on the current directory and all subdirectories
  • It will modify read-only files
  • It will consider all .csproj and .sln files, potentially destroying non-Silverlight project files – so use caution if the current directory or sub-directory contains other project types
  • This is C#-only, though a similar exercise for .vbproj files would not be that bad
  • This will delete .suo and .user files that may contain version-specific binary data, so you may lose your local settings (such as the current startup project you have set locally)
  • This ‘works on my machine’ and I am not responsible for data loss in any way
  • This code is not efficient nor elegant. Get over it! I did!

Download the binary and source [21.8K, Zip]

I have included the source, Ms-PL licensed, because though awful, maybe someone can do something much better with it!

Convert all C# projects and solutions to Visual Studio 2010

Move into the root directory of your solution in a command prompt window, and provide the path to the ThereAndBackAgain.exe file. It will recurse the current directory.

pushd c:\myEnlistment\myProject\Silverlight\

c:\tools\ThereAndBackAgain.exe 2010 <enter>

You’ll see a quick list of what is changed. You can run this on a directory tree that is already converted, and it should not be affected.

Convert back to Visual Studio 2008

Pretty similar:

pushd c:\myEnlistment\myProject\Silverlight\

c:\tools\ThereAndBackAgain.exe 2008 <enter>

Final note

This works for me. Uh and so no promises beyond that. I literally just diff’d a new VS 08 and VS 2010 Silverlight project and wrote something to move between the two. Nothing fancy.

If you go this route, remember to convert back your projects and solutions using the tool before checking in! You don’t want to break the build, or a teammates’ development experience.

Hope this helps. Again, I wrote this script specifically to meet my needs, but it is FAR from production-ready. You are on your own, feel free to take and run with this.

Jeff Wilcox is a Software Engineer at Microsoft in the Open Source Programs Office (OSPO), helping Microsoft engineers use, contribute to and release open source at scale.

comments powered by Disqus