I have the powershell code below which will get all the projects in the solution, by name.
However, I want to get just those projects which start with "Test" (ignore the -match bit as I have played with various things). What am I missing?
cd C:\SourceControlledProjects\ClassLibrary1
gc ClassLibrary1.sln | ? { $_ -match "^Pro开发者_JAVA百科ject" } | % { ($.Split(","))[1].Trim().Trim('"') } | ? { $ -match ".*proj" } | % { $x = [xml](gc $); $x.Project.PropertyGroup[0].AssemblyName } % { $ + ".dll" } | Format-Table | Where {$_ -match "TestProject1"}
Thanks
This should make life easier:
gc .\test.sln |
Where-Object {
$_.StartsWith("Project(")
} |
ForEach-Object {
$name, $relativePath, $guid = ($_ -split '=' | Select-Object -Skip 1) -split '[,"]' |
Where-Object { $_.Trim() }
New-Object PSObject -Property @{
Name = $name
RelativePath = $relativePath
Guid = $guid
}
}
This turns the output into a property bag, from there on in, it's just:
| Where-Object { $_.Name -like "test*" }
Hope this Helps
精彩评论