Project("{00000000-0000-0000-0000-000000000000}") = "Test Projects", "TestProjects", "{5FAF487E-B913-4D46-983E-CB13FDF36FCB}"
EndProject
Project("{11111111-1111-1111-1111-111111111111}") = "ProjPropHelperAPI", "ProjPropHelperAPI\ProjPropHelperAPI.vcxproj", "{22222222-2222-2222-2222-222222222222}"
EndProject
Project("{33333333-3333-3333-3333-333333333333}") = "ProjectPropertiesHelperAPI", "ProjectPropertiesHelperAPI\ProjectPropertiesHelperAPI.csproj", "{66666666-6666-6666-6666-666666666666}"
ProjectSection(ProjectDependencies) = postProject
{44444444-4444-4444-4444-444444444444} = {44444444-4444-4444-4444-444444444444}
{55555555-5555-5555-5555-555555555555} = {55555555-5555-5555-5555-555555555555}
EndProjectSection
EndProject
我可以使用 to this question 提到的解决方案阅读项目名称,其GUID和路径。使用
访问名称,guid和路径Type.GetType().GetProperty()
我需要解析ProjectDependencies选项卡。我想知道是否可以类似地获得ProjectDependencies值?
欢迎任何其他解决方案
提前致谢!!
答案 0 :(得分:0)
var filePath = @"C:\Users\xyz\Documents\Visual Studio 2010\Projects\test\test.sln"
var slnLines = File.ReadAllLines(filePath);
var projGuid = new List<string>();
for(var i=0; i<slnLines.Length; i++)
{
if (slnLines[i].Contains(@"ProjectSection(ProjectDependencies)"))
while (!slnLines[i+1].Contains("EndProjectSection"))
{
var temp = (slnLines[i+1].Split(new[]{'=', '\n', '\t', ' '},2,StringSplitOptions.RemoveEmptyEntries));
if(temp.ElementAt(0) == temp.ElementAt(1))
projGuid.Add(temp.ElementAt(0));
i++;
}
}
using (var file = new StreamWriter(@"C:\Users\xyz\Desktop\Results.txt"))
{
foreach (var pGuid in projGuid)
{
file.WriteLine(pGuid);
}
}
这段代码就是这样做的。
感谢。