BuildDependency.RemoveProject メソッド

更新 : 2007 年 11 月

プロジェクトがビルドされる順序を指定する一覧から、プロジェクトを削除します。

名前空間 :  EnvDTE
アセンブリ :  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Sub RemoveProject ( _
    ProjectUniqueName As String _
)
'使用
Dim instance As BuildDependency
Dim ProjectUniqueName As String

instance.RemoveProject(ProjectUniqueName)
void RemoveProject(
    string ProjectUniqueName
)
void RemoveProject(
    String^ ProjectUniqueName
)
function RemoveProject(
    ProjectUniqueName : String
)

パラメータ

  • ProjectUniqueName
    型 : System.String

    必ず指定します。依存関係として追加する UniqueName プロパティのプロジェクトの名前。

この例は Visual Studio .NET 2003 でのみ動作します。詳細については、「方法 : テンプレートを使用したプロジェクト作成コードを移行する」を参照してください。

Sub RemoveProjectExample(ByVal dte As DTE)

    ' NOTE: This example requires a reference to the 
    '       VSLangProj namespace.

    ' Create a new solution.
    Dim soln As Solution = dte.Solution
    Dim solnName As String = "NewSolution.sln"
    Dim tempPath As String = System.IO.Path.GetTempPath()
    soln.Create(tempPath, solnName)

    ' Create two new Visual Basic Console Application projects.
    Dim templatePath As String = _
        dte.Solution.TemplatePath(PrjKind.prjKindVBProject)
    templatePath &= "ConsoleApplication.vsz"
    Dim projName As String = "Project1"
    soln.AddFromTemplate(templatePath, tempPath & projName, projName)
    Dim proj1 As Project = soln.Item(1)
    projName = "Project2"
    soln.AddFromTemplate(templatePath, tempPath & projName, projName)
    Dim proj2 As Project = soln.Item(2)

    ' Make Project1 dependent on Project2.
    Dim bd As BuildDependency = _
        soln.SolutionBuild.BuildDependencies.Item(proj1.UniqueName)
    bd.AddProject(proj2.UniqueName)

    ' Enumerate Project1's dependencies.
    Dim depends As String = ""
    Dim proj As Project
    For Each proj In CType(bd.RequiredProjects, Array)
        depends &= proj.Name & vbCrLf
    Next

    MsgBox(bd.Project.Name & " has the following dependencies:" & _
        vbCrLf & vbCrLf & depends)

    If MsgBox("Remove dependency on " & proj2.Name & " from " & _
        bd.Project.Name & "?", MsgBoxStyle.YesNo) = _
        MsgBoxResult.Yes Then
        bd.RemoveProject(proj2.UniqueName)

        ' Enumerate Project1's dependencies.
        depends = ""
        For Each proj In CType(bd.RequiredProjects, Array)
            depends &= proj.Name & vbCrLf
        Next

        MsgBox(bd.Project.Name & " has the following dependencies:" & _
            vbCrLf & vbCrLf & depends)
    End If

End Sub
public void RemoveProjectExample(DTE dte)
{
    // NOTE: This example requires a reference to the 
    //       VSLangProj namespace.

    // Create a new solution.
    Solution soln = dte.Solution;
    string solnName = "NewSolution.sln";
    string tempPath = System.IO.Path.GetTempPath();
    soln.Create(tempPath, solnName);

    // Create two new C# Console Application projects.
    string templatePath = 
        dte.Solution.get_TemplatePath(PrjKind.prjKindCSharpProject);
    templatePath += "CSharpConsole.vsz";
    string projName = "Project1";
    soln.AddFromTemplate(templatePath, tempPath + projName, 
        projName, false);
    Project proj1 = soln.Item(1);
    projName = "Project2";
    soln.AddFromTemplate(templatePath, tempPath + projName, 
        projName, false);
    Project proj2 = soln.Item(2);

    // Make Project1 dependent on Project2.
    BuildDependency bd = 
        soln.SolutionBuild.BuildDependencies.Item(proj1.UniqueName);
    bd.AddProject(proj2.UniqueName);

    // Enumerate Project1's dependencies.
    string depends = "";
    foreach (Project proj in (Array)bd.RequiredProjects)
    {
        depends += proj.Name + Environment.NewLine;
    }

    MessageBox.Show(bd.Project.Name + 
        " has the following dependencies:" + Environment.NewLine + 
        Environment.NewLine + depends);

    if (MessageBox.Show("Remove dependency on " + proj2.Name + 
        " from " + bd.Project.Name + "?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        bd.RemoveProject(proj2.UniqueName);

        // Enumerate Project1's dependencies.
        depends = "";
        foreach (Project proj in (Array)bd.RequiredProjects)
        {
            depends += proj.Name + Environment.NewLine;
        }

        MessageBox.Show(bd.Project.Name + 
            " has the following dependencies:" + Environment.NewLine + 
            Environment.NewLine + depends);
    }
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

BuildDependency インターフェイス

BuildDependency メンバ

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する