Share via


BuildDependency.Project Property

Gets the Project associated with the object.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
ReadOnly Property Project As Project
'Usage
Dim instance As BuildDependency 
Dim value As Project 

value = instance.Project
Project Project { get; }
property Project^ Project {
    Project^ get ();
}
function get Project () : Project

Property Value

Type: EnvDTE.Project
A Project object.

Remarks

The Project property represents the project to which the item belongs. Returns the project that has a list of dependencies.

Examples

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

Sub ProjectExample(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 VB 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)

End Sub
public void ProjectExample(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:" + "\r\n\r\n" + depends);
}

.NET Framework Security

See Also

Reference

BuildDependency Interface

BuildDependency Members

EnvDTE Namespace

Other Resources

How to: Compile and Run the Automation Object Model Code Examples