SolutionBuild2.BuildState SolutionBuild2.BuildState SolutionBuild2.BuildState SolutionBuild2.BuildState SolutionBuild2.BuildState Property


Gets whether a build has ever been started in the current environment session, whether a build is currently in progress, or whether a build has been completed.

 property EnvDTE::vsBuildState BuildState { EnvDTE::vsBuildState get(); };
 property EnvDTE::vsBuildState BuildState { EnvDTE::vsBuildState get(); };
[get: System.Runtime.InteropServices.DispId(5)]
public EnvDTE.vsBuildState BuildState { get; }
member this.BuildState : EnvDTE.vsBuildState
Public ReadOnly Property BuildState As vsBuildState
Property Value

A vsBuildState value representing the status of the build operation.



This example determines the build state for each active startup configuration. Open a project in the Visual Studio integrated development environment (IDE) before running this example.

Imports EnvDTE  
Imports EnvDTE80  
Sub SolutionBuild2Example(ByVal dte As DTE2)  
    ' Open a solution in the Visual Studio IDE  
    ' before running this example.  
        Dim sb As SolutionBuild2  
        sb = CType(_applicationObject.Solution.SolutionBuild _  
        , SolutionBuild2)  
        Dim sc As SolutionConfiguration2  
        sc = CType(sb.ActiveConfiguration, SolutionConfiguration2)  
        Dim vsBldSt As vsBuildState  
        Dim msg As String = "Return relative path to startup  _  
        projects: "  
        For Each s As String In CType(sb.StartupProjects, Array)  
            msg &= vbCr & " " & s  
        msg &= vbCr & "SolutionConfiguration: " & sc.Name  
        vsBldSt = sb.BuildState  
        If (vsBldSt = vsBuildState.vsBuildStateDone) Then  
            msg &= vbCr & "A build has occurred."  
        ElseIf (vsBldSt = vsBuildState.vsBuildStateInProgress) Then  
            msg &= vbCr & "A build is in progress."  
        Else : msg &= vbCr & "A build has not occurred."  
        End If  
    Catch ex As System.Exception  
    End Try  
End Sub  
using EnvDTE;  
using EnvDTE80;  
using System.Windows.Forms;  
public void SolutionBuild2Example(DTE2 dte)  
        SolutionBuild2 sb =  
        SolutionConfiguration2 sc =  
        vsBuildState vsBS;  
        string msg = "Return relative path to startup projects: ";  
        foreach (String s in (Array)sb.StartupProjects)  
            msg += "
" + s; } msg += "
SolutionConfiguration: " + sc.Name; vsBS = sb.BuildState; if (vsBS == vsBuildState.vsBuildStateDone) msg += "
A build has occurred."; else if (vsBS == vsBuildState.vsBuildStateInProgress) msg += "
A build is in progress."; else msg += "
A build has not occurred."; MessageBox.Show(msg); } catch(Exception ex) { MessageBox.Show(ex.Message); } }


BuildState has vsBuildStateNotStarted so that you can detect a race condition, a process that starts the environment to do a build and then checks its build state before the build has actually begun. Checking to see if vsBuildState equals vsBuildStateNotStarted allows you to avoid this situation. It also allows you to determine whether the value of the LastBuildInfo property is valid.

Applies to