csharp Foreach sln for csproj解析sln中的每个csproj
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp Foreach sln for csproj解析sln中的每个csproj相关的知识,希望对你有一定的参考价值。
List<DevOpsFileInformation> solutions = devOps.SearchResult("ext:sln");
foreach(var solution in solutions)
{
VsSolution vsSolution = null;
try
{
string wholeFile = devOps.GetFileContent(solution);
vsSolution = devOps.ParseSolution(wholeFile);
}
catch(FileNotFoundException)
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine($"Nemam prava na solution: {solution.path}");
System.Console.ResetColor();
continue;
}
System.Console.ForegroundColor = System.ConsoleColor.Green;
System.Console.WriteLine("Solution: " + solution.path);
System.Console.ResetColor();
foreach(var project in vsSolution.Projects)
{
if(project.Path.Contains(".csproj"))
{
string pathOfCsProjInProject = project.Path;
string content = devOps.GetFileContent(new DevOpsFileInformation()
{
repository = solution.repository,
path = solution.path.Substring(0, solution.path.LastIndexOf("/")) + "/" + pathOfCsProjInProject,
project = new Project()
{
name = solution.project.name
}
});
try
{
var parsedProject = devOps.ParseCSPROJ(content);
System.Console.ForegroundColor = System.ConsoleColor.Yellow;
System.Console.WriteLine($"\t{project.Name} " + "ima FRAMEWORK VERSION: " + devOps.GetFrameworkVersion(parsedProject));
System.Console.ResetColor();
}
catch(System.Exception ex)
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
System.Console.WriteLine($"Ne mogu parsirati: {project.Name} " + " PROBLEM: " + ex.Message);
System.Console.ResetColor();
}
}
else
{
continue;
}
}
}
以上是关于csharp Foreach sln for csproj解析sln中的每个csproj的主要内容,如果未能解决你的问题,请参考以下文章
对字符串值使用foreach的For循环
csharp CSHARP-1-3.cs
csharp GetHTMLContentsWithEmbeddedResources.cs.cs
csharp GetHTMLContentsWithEmbeddedResources.cs.cs
csharp GetHTMLContentsWithEmbeddedResources.cs.cs
csharp 示例 - CSHARP - 数据层,GetCustomerDataJson.cs