How can I parse Visual Studio solution (SLN) files in .NET? I would like to write an app that merges multiple solutions into one while saving the relative build order.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- Correctly parse PDF paragraphs with Python
I don't know if anyone is still looking for solutions to this problem, but I ran across a project that seems to do just what is needed. https://slntools.codeplex.com/ One of the functions of this tool is to merge multiple solutions together.
Answer by @john-leidegren is great. For pre-VS2015, this is of great use. But there was a minor mistake, as the code to retrieve configurations was missing. So wanted to add it, in case someone is struggling to use this code.
The enhancement is very simple:
As additional help, providing simple code to browse through the properties of a
System.Type
as suggested by @oasten.we solved a similar problem of merging solutions automatically by writing a Visual Studio plugin which created a new solution then searched for *.sln file and imported them into the new one using:
Our problem was slightly different in that we wanted VS to sort out the build order for us, so we then converted any dll references to project references where possible.
We then automated this into a build process by running VS via COM automation.
This solution was a little Heath Robinson, but had the advantage that VS was doing the editing so our code was not dependant on format of the sln file. Which was helpful when we moved from VS 2005 to 2008 and again to 2010.
I expounded, determined that the MSBuild classes can be used to manipulate the underlying structures. I will have further code on my web site later.