共用方式為


SolutionBuild2.StartupProjects 屬性

取得或設定做為應用程式進入點的專案名稱。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
Property StartupProjects As Object
Object StartupProjects { get; set; }
property Object^ StartupProjects {
    Object^ get ();
    void set (Object^ value);
}
abstract StartupProjects : Object with get, set
function get StartupProjects () : Object
function set StartupProjects (value : Object)

屬性值

型別:System.Object
物件,內含做為應用程式進入點的專案名稱。

備註

StartupProjects 包含一份專案名稱字串清單,當發出 Run 命令就會「啟動」。各個專案和語言定義出啟動的意義,以及專案啟動後發生的情形。例如,執行 Visual C++ 函式會啟動 main() 專案,而 Visual Basic 則會執行 Sub Main() 或啟動表單。其他專案及語言利用專案屬性做為類別或函式名稱,其餘的是利用必須實作的介面等等。

範例

這個範例會決定每個使用中之啟動設定的建置狀態。執行這個增益集之前,先開啟 Visual Studio 整合式開發環境 (IDE) 中的專案。

如需如何像執行增益集一般,執行這個範例的詳細資訊,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例

Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    SolutionBuild2Example(_applicationObject)
End Sub
Sub SolutionBuild2Example(ByVal dte As DTE2)
    ' Open a solution in the Visual Studio IDE
    ' before running this example.
    Try
        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
        Next
        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
        MsgBox(msg)
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application, 
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    SolutionBuild2Example(_applicationObject);
}
public void SolutionBuild2Example(DTE2 dte)
{
    try
    {
        SolutionBuild2 sb =
 (SolutionBuild2)_applicationObject.Solution.SolutionBuild;
        SolutionConfiguration2 sc =
 (SolutionConfiguration2)sb.ActiveConfiguration;
        vsBuildState vsBS;
        string msg = "Return relative path to startup projects: ";
        foreach (String s in (Array)sb.StartupProjects)
        {
            msg += "\n   " + s;
        }
        msg += "\nSolutionConfiguration: " + sc.Name;
        vsBS = sb.BuildState;
        if (vsBS == vsBuildState.vsBuildStateDone)
            msg += "\nA build has occurred.";
        else if (vsBS == vsBuildState.vsBuildStateInProgress)
            msg += "\nA build is in progress.";
        else msg += "\nA build has not occurred.";
        MessageBox.Show(msg);
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

SolutionBuild2 介面

StartupProjects 多載

EnvDTE80 命名空間