Thursday, August 18, 2011

Visual Studio: Setting multiple startup projects via macro

UPDATE: For Visual Studio 2010 (and later?) see comments or

According to the documentation, this should work: Sub StartUpProj() Dim sb As SolutionBuild = DTE.Solution.SolutionBuild Dim startupProjects() As String = { "Project1.vcproj", "Project2.vcproj" } sb.StartupProjects = startupProjects End Sub Unfortunately, it also says in the MSDN here:

The StartupProjects collection in the current version of Visual Studio .NET allows you to set only a single startup project, but future versions will allow multiple startup projects.
This was written for Visual Studio .NET 2003 and still holds true for Visual Studio 2008. At least this works for setting a single startup project: Sub StartUpProj() Dim sb As SolutionBuild = DTE.Solution.SolutionBuild sb.StartupProjects = "Project1.vcproj" End Sub BTW: Above examples are for C/C++ projects. For other types of projects the extensions vary.


  1. Hi Matthias!

    Thanks yor your post.
    In Visual Studio 2010, multiple startup projects are indeed possible. One needs to really use the right types though.
    I 've summarized my findings here:


  2. I am also interested in the ability to set multiple startup projects via DTE ... but Tom Paschenda's post appears to no longer be available. Can you provide any additional information on what the solution was?

    1. Tom Paschenda's post is online again. Anyway, this is his example code:

      Public Sub SetMyStartupProjects()

      'Create an array and fill it with the startup projects you would like to set
      Dim StartupProjectsArray As Object = System.Array.CreateInstance(GetType(Object), 3)
      StartupProjectsArray(0) = "MyProj1.vcxproj"
      StartupProjectsArray(1) = "MyProj2.vcxproj"
      StartupProjectsArray(2) = "MyProj3.vcxproj"

      'Set the startup projects of the current solution
      Dim CurrentSolutionBuild As SolutionBuild = DTE.Solution.SolutionBuild
      CurrentSolutionBuild.StartupProjects = StartupProjectsArray

      End sub