I'd like to write a macro to crawl through the files in my project directory and find files that aren't included in the project.
In playing around with the DTE object, I see that the Project
object has ProjectItems
; if a ProjectItem
represents a directory, then it has its own ProjectItems
collection. This gives me all files that are included in the project.
So I could crawl recursively through each ProjectItems collection, and for each ProjectItem that's a directory, check to see if there are files in the file system that don't have a corresponding ProjectItem. This seems clumsy, though.
Any ideas of a simpler way to approach this?
Thanks to @JaredPar and @lpthnc for pointing me in the right direction. I ended up using an approach very similar to what @JaredPar outlines above. Here's my working macro FWIW.
Here is the C# version of your code:
The approach I would take is to
Here is a quick bit of sample code
I'd go with PowerShell. The PowerShell script in my other post will do this for you. The script will get the list of included files from the project file and compare that against the files on disk. You will get the set of files that are on disk but not included in the project. You can either delete them or pend them as deletes for TFS.
https://stackoverflow.com/a/23420956/846428