VS2010 Build and Debug Startup Project

4 11 2011

In large solutions, I often have the need to build and/or debug only the selected startup project.

The main benefit of this is that Visual Studio keeps from building the entire solution when you select Debug – Start new instance from a project’s context menu in the Solution Explorer view. This is different from the behavior when you select Debug – Start Debugging from the main menu. In the latter case, the whole solution is always built which might cause problems when one or more of the generated output artefacts are in use by the system (e. g. running executables).

Today I wrote the following two Visual Studio macros and assigned them to the hotkey Ctrl+B (BuildStartupProject) and Ctrl+D (DebugStartupProject) and it made me happier.

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics

Public Module StartupProjectCommands
Sub BuildStartupProject()
  ' Build startup project
  Dim sb As SolutionBuild = DTE.Solution.SolutionBuild
  Dim projName As String = sb.StartupProjects(0)
  sb.BuildProject(sb.ActiveConfiguration.Name, projName, False)
End Sub

Sub DebugStartupProject()
  ' Get startup project name
  Dim sb As SolutionBuild = DTE.Solution.SolutionBuild
  Dim projName As String = sb.StartupProjects(0)
  Dim index As Integer = projName.LastIndexOf(".")
  If (index > 0) Then
    projName = projName.Substring(0, index)
    ' Activate SolutionExplorer
    ' Select startup project
    ' Debug startup project
  End If
End Sub

End Module

Visual Studio 2010 Beta 2

31 10 2009

Now also non MSDN subscribers can download the Visual Studio 2010 Beta 2 Bits not only through the Web Installer, but also as an offline Microsoft Visual Studio 2010 Ultimate Beta 2 – ISO.

If you have problems installing or using the Online Documentation please read Unable to install Vs2010 beta 2 Documentation and Setting up Offline help/Docs in Visual Studio 2010 Beta2.

VS2003 Custom Build Step/Additional Dependencies ignored

21 10 2009

There is a bug in VS2003 that causes dependent files which have been specified in the „Additional Dependencies“ property of a „Custom Build Step“ configuration to be ignored.

Workaround: Close and reopen the solution (.sln) file.

See also these posts: