Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the Startup Project setting stored for a solution?

Tags:

When I right-click my solution in the Solution Explorer and choose Properties I get a dialog where I can select the Startup Project.

I sometimes select Current selection (If it is an experimental solution with lots of projects I jump between), but most often it is a Single startup project selected, which would usually be the main WinForms applications or or Console application.

My problem is that whenever I do a treeclean with the tfpt command (Team Foundation Power Tools 2008) this setting is forgotten. So when I try to run my solution the next time, it has defaulted to some random project and I get an error stating that I cannot run a class library or something like that. Which is obvious of course. But where is this setting stored? Why is it forgotten when I do the treeclean? The solution file is still there, right? Isn't solution properties stored there?

like image 714
Svish Avatar asked Aug 06 '09 12:08

Svish


1 Answers

Reference 1

Arian Kulp says:

I was struggling with trying to figure out why a certain solution of mine wasn’t starting right. It was in VB with four projects. Upon initial open it would set a certain project with a DLL output as startup. If I set the EXE as startup project, it was fine, but when I distribute code I always clean it by removing *.suo and *.user files, and bin/obj folders. Upon opening the “cleaned” version, it would always revert to the DLL project and fail to F5 nicely. The fix turned out to be simple, though I’m curious as to why I needed to do this at all.

In the solution file, there are a list of pseudo-XML “Project” entries. It turns out that whatever is the first one ends up as the Startup Project, unless it’s overridden in the suo file. Argh. I just rearranged the order in the file and it’s good.

I’m guessing that C# is the same way but I didn’t test it. I hope that this helps someone!

Reference 2

Setting the StartUp Project

Which project is the "startup" project only has any relevance for debugging, which means it's user metadata from the point of the solution and the projects. Regardless of which project is the "startup" project, the compiled code is the same.

Because of this, the information is stored as a user setting in the Solution User Options file (solution.suo) which accompanies the Solution file (solution.sln). The .suo file "Records all of the options that you might associate with your solution so that each time you open it, it includes customizations that you have made" according to MSDN.

The .suo file is a binary file. If you want to read or change it programatically, you have to use IVsPersistSolutionOpts.LoadUserOptions from the Microsoft.VisualStudio.Shell.Interop namespace.

like image 56
Kirtan Avatar answered Sep 24 '22 03:09

Kirtan