Default Startup Projects in VS 2005

Published on July 28, 2008

I ran across another weird and subtle bug in Visual Studio 2005. If you’ve got a solution with many project in it, you can set one of those projects to be the default project at startup (i.e. when you open the solution file). But this setting apparently resides in the user options file (.suo), which is something we don’t keep in our code repository (since it differs for every user). So how can you set a default startup project that affects anyone working with your code? Simple: hack the solution file.

Thankfully, the solution file is just plain text. Apparently, if there’s no user options file for a given solution, Visual Studio 2005 simply selects the first project it comes across in the solution file. Here’s a quick example of what a solution file looks like (wrapped lines marked with »):

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{3853E850-5CD7-11DD-AD8B-0800200C9A66}") = "ProjectA", »
"projecta.vcproj", "{D9BA97DE-0D09-4C35-99D6-CC4C30A6279C}"
EndProject
Project("{3853E850-5CD7-11DD-AD8B-0800200C9A66}") = "ProjectB", »
"projectb.vcproj", "{E1D73B44-57D9-4202-A92A-0296E3583AC4}"
EndProject
Global
{ ... a bunch of junk goes here ... }
EndGlobal

In this case, Project A will be the default startup project. To make Project B the default, simply move its associated lines above Project A in the file, like so:

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{3853E850-5CD7-11DD-AD8B-0800200C9A66}") = "ProjectB", »
"projectb.vcproj", "{E1D73B44-57D9-4202-A92A-0296E3583AC4}"
EndProject
Project("{3853E850-5CD7-11DD-AD8B-0800200C9A66}") = "ProjectA", »
"projecta.vcproj", "{D9BA97DE-0D09-4C35-99D6-CC4C30A6279C}"
EndProject
Global
{ ... a bunch of junk goes here ... }
EndGlobal

Don’t forget to grab the end tags of each project (and any child content that may live between them).

Comments are closed.

Copyright © 2004-2018 Jonah Bishop. Hosted by DreamHost.