I am trying to read a .sln file and extract the strings that contain the path to the .csproj within my solution.
The lines that contain the information that I am looking for look like this:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project", "Project\Project.csproj", "{0DB516E6-4358-499D-BFBF-408F50A44E14}"
So, this is what I am trying:
$projectsInFile = Select-String "$slnFile" -pattern '^Project'
$csprojectsNames = $projectsInFile -replace ".+= `"(\S*) `""
Now, $csprojectsName contain the information that I am looking for, but also the rest of the string.
Just like this:
Project\Project.csproj", "{0DB516E6-4358-499D-BFBF-408F50A44E14}"
What is the best way to retrieve the name of the .csproj file without needing to manually cut the rest of the string?
Thank you
$projectsInFile -replace '.+= "(\S*) "(.*?)",.*"','$2'working on cleaner ways. Put the part you want to keep in a group. Eat up the whole string and just replace it with the second group which has the string you want. Could also consider splitting on commas.... but that would only be useful if the structure was the same