Please click this logo to help me get on their beta program:

Xobni outlook add-in for your inbox








4/9/2005

Accessing project properties from a VS macro

Filed under: General, Programming, .NET, VSIP — Oliver Sturm @ 6:03 pm - 3 years, 2 months ago

I saw this question on a newsgroup: How do you access the properties of a project via the EnvDTE VS extensibility interface? It’s really quite simple, like in this code:

Sub AccessProject()
  Dim proj As Project
  proj = DTE.Solution.Projects.Item(1)
  Dim prop As [Property]
  For Each prop In proj.Properties
    Debug.Print("Project property " & prop.Name & " = " & prop.Value)
  Next
  Dim projItem As ProjectItem
  For Each projItem In proj.ProjectItems
    Debug.Print("Project item " & projItem.Name)
  Next
End Sub

This will simply print out all the project properties and items it finds. The sample accesses only the first entry in the solution’s Projects list - you can directly access other specific members in a similar way, of course, and it’s also possible to find the currently active project(s) via the DTE.ActiveSolutionProjects:

Dim projects as System.Array = DTE.ActiveSolutionProjects
Dim proj as Project
	
For Each proj In projects
  Debug.Print(proj.Name)
Next

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Powered by WordPress
© Copyright 2005-2008 Oliver Sturm