views:

46

answers:

3

I have solution sln, that has many csproj projects (P1.csproj, P2.csproj, P3.csproj...).

anyone know a way to programmatically (using scripting-commandline, APIs, or SDKs) read the list of all csproj projects in a VS2008 of sln file?

+4  A: 

just read the list from *.sln file. There are "Project"-"EndProject" sections.
Here is an article from MSDN.

MAKKAM
any sample code? A question: why csproj files are XML, and why not sln files ??
alhambraeidos
+1  A: 

If you write your program as Visual Studio Add-in you can access the EnvDTE to find out all the projects within the currently opened solution.

Oliver
any sample code ?
alhambraeidos
+2  A: 

Here's a PowerShell script that retrieves project details from a .sln file:

Get-Content 'Foo.sln' |
  Select-String 'Project\(' |
    ForEach-Object {
      $projectParts = $_ -Split '[,=]' | ForEach-Object { $_.Trim('[ "{}]') };
      New-Object PSObject -Property @{
        Name = $projectParts[1];
        File = $projectParts[2];
        Guid = $projectParts[3]
      }
    }
brianpeiris