Eddie Parker
Eddie Parker

Reputation: 4888

Visual Studio Macro To Switch Solution Configuration

I'm trying to write a macro that toggles between release/debug solution configurations in Visual Studio.

It appears I can switch the configuration by using 'DTE.ExecuteCommand("Build.SolutionConfigurations", "Debug")'.

Is there a way I can 'read' the value? Or is there a way I can use macros to 'focus' on the solution configuration UI element?

Upvotes: 2

Views: 1048

Answers (2)

Acteon
Acteon

Reputation: 11

Here ready macros for that:

Sub ConfigurationToggle()
    Dim current As String = DTE.Solution.Projects.Item(1).ConfigurationManager.ActiveConfiguration.ConfigurationName
    If current = "Debug" Then
        DTE.ExecuteCommand("Build.SolutionConfigurations", "Release")
    Else
        DTE.ExecuteCommand("Build.SolutionConfigurations", "Debug")
    End If
End Sub

Upvotes: 1

Eddie Parker
Eddie Parker

Reputation: 4888

Hrmm. Digging made me find this bit of code:

    DTE.ExecuteCommand("Build.ConfigurationManager")

Which will bring up the configuration manager and allow me to bring up the configuration manager which has the 'configuration' selected so I can switch in a jiffy.

Although looking into it, it looks like that's already key-bindable if I use 'Build.ConfigurationManager', so maybe I don't need the scripts after all.

Anyhow, I'd still like this question answered if possible, so I'll keep it open in case it's useful for someone else.

Upvotes: 1

Related Questions