Tuesday, October 9, 2012

TIP - Set StartUp Project in Visual Studio solution file

When Visual Studio opens a solution (.sln), the default StartUp project is the first project listed in the solution file. 

The default StartUp project can be overridden by the developer by changing the StartUp project manually through the context menu. Visual Studio will see it as a user-specific preference and hence store this within its '.suo' file. 

The rule is "if you don't have a .suo file in your solution directory, Visual Studio picks the first one as the default StartUp project". 

Now, for projects on a source code repository, it is not advisable to store the 'suo' file. This means that each time a fresh checkout of the code is done, the default StartUp project is used when Visual Studio opens the solution. 

TIP: to change the default StartUp project, 

1) Open the solution file (.sln) in a text editor (e.g. notepad) 
2) You will see all your project entries within the solution encapsulated in a Project ... EndProject lines. 
3) Cut and paste the desired StartUp project to the top position. 
4) Commit your updated solution file (.sln) on the code repository 

And in the next fresh checkout, you have the correct StartUp project ;-)