I want to get all of the files under a ProjectItem with powershell
In the above I want the paths for the following files:
- Web.config
- Web.Debug.config
- Web.Release.config
I can get the ProjectItem without any problems but I cant work out how to enumerate the FileNames array. All of the elements seem to point to the same thing so I think I must be enumerating the array wrong.
$projectItem.FileNames(0) => Path to web.config
$projectItem.FileNames(1) => Path to web.config
Any number here seems to return the same file path.
How do I get all 3 file paths from the ProjectItem in powershell
To try this out put this in the Package Manager Console of a web project:
@(Get-Project).ProjectItems | Where {$_.Name.StartsWith("Web") } | Select { $_.FileNames(0) }
Got it. Basically you have to expand the
ProjectItems
collection of theProjectItem
namedWeb.config
. There may be a simpler way, though.