blog

I like to blog about current software design and development projects, as well as general everyday news and events. I'm passionate about what I do and you can follow my personal journey through my blog. I'm constantly on the lookout for new development techniques and technologies to keep on top of the changing market, so if I do miss anything feel free to leave me a comment.

Visual Studio: How to build only the StartUp project

Have you ever found yourself working on a Visual Studio solution consisting of multiple projects and wanting to build only the start-up project using a shortcut key?

Unfortunately for some bizarre reason Visual Studio 2005 and 2008 do not have this feature by default.  However, there is a simple solution to this. Create a macro and assign it a shortcut key.

First create a new macro module though Tools > Macros with the following code

1
2
3
4
5
6
7
8
9
10
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
 
Public Module BuildStartup
    Sub BuildStartup()
        DTE.Solution.SolutionBuild.BuildProject(DTE.Solution.SolutionBuild.ActiveConfiguration.Name, DTE.Solution.SolutionBuild.StartupProjects(0), False)
    End Sub
End Module

Now that you have the macro, you simply assign it a shortcut key through Tools > Options.  Look for “Keyboard” under “Environment”.  Find your macro in the command list and assign it a shortcut key.

Enjoy.

Tags: ,

One Response to “Visual Studio: How to build only the StartUp project”

  1. Jeremy // May 15th, 2009 at 2:48 am

    I was looking for something exactly like this. I found that it wouldn’t necessarily build the correct Solution Platform though (e.g. x86, x64). So I hacked together a Macro that should work for the current configuration. Warning: I know nothing about Visual Basic/Macros but this is certified Works For Me:

    Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports System.Diagnostics

    Public Module BuildStartupProject
    Sub BuildStartupProject()
    Dim sb2 As EnvDTE80.SolutionBuild2 = CType(DTE.Solution.SolutionBuild, EnvDTE80.SolutionBuild2)
    Dim config2 = CType(sb2.ActiveConfiguration, EnvDTE80.SolutionConfiguration2)
    Dim configName = String.Format(“{0}|{1}”, config2.Name, config2.PlatformName)
    DTE.Solution.SolutionBuild.BuildProject(configName, DTE.Solution.SolutionBuild.StartupProjects(0), False)
    End Sub
    End Module

Leave a Reply