次の方法で共有


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)

プロパティ値

型 : Object
アプリケーションのエントリ ポイントであるプロジェクトの名前を格納しているオブジェクト。

解説

StartupProjects には、Run コマンドの実行時に "起動" するプロジェクト名文字列の一覧が格納されます。 起動の方法およびプロジェクトが起動されたときの動作は、プロジェクトおよび言語ごとに定義されます。 たとえば、プロジェクトを起動するときに、Visual C++ の場合は main() 関数を実行し、Visual Basic の場合は Sub Main() またはスタートアップ フォームを実行します。 プロジェクト プロパティをクラス名または関数名として使用したり、インターフェイスを実装して使用したりするプロジェクトと言語もあります。

この例では、アクティブな起動構成ごとにビルド状態を決定します。 このアドインを実行する前に、Visual Studio 統合開発環境 (IDE: integrated development environment) でプロジェクトを開きます。

このアドインの例を実行する方法の詳細については、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

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 インターフェイス

EnvDTE80 名前空間