1

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 "^Project" } | % { ($.Split(","))[1].Trim().Trim('"') } | ? { $ -match ".*proj" } | % { $x = [xml](gc $); $x.Project.PropertyGroup[0].AssemblyName } % { $ + ".dll" } | Format-Table | Where {$_ -match "TestProject1"}

Thanks

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.