Share via


BuildDependency.RemoveProject(String) Method

Definition

Removes a project from the list that specifies the order in which projects are built.

public:
 void RemoveProject(Platform::String ^ ProjectUniqueName);

Parameters

ProjectUniqueName
String

Required. The name of the project from the UniqueName property to add as a dependency.

Attributes

Examples

This example works only in Visual Studio .NET 2003. For more information, see Migrating Code that Creates Projects by Using Templates.

Sub RemoveProjectExample(ByVal dte As DTE)  

    ' 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 = <template path>  
    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  

Applies to