add solution parser

This commit is contained in:
Maksim Chegulov 2021-10-22 19:57:33 +03:00
parent c02e5867d7
commit 5334e97313

View File

@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.Build.Construction;
namespace AutoMigrationCreator.Core
{
public class Solution
{
private const string SOLUTION_NAME = "ASC.Tools.sln";
public IEnumerable<ProjectInfo> GetProjects()
{
var solutionPath = Path.GetFullPath(Path.Combine("..", "..", "..", SOLUTION_NAME));
var source = SolutionFile.Parse(solutionPath);
var currentAssembly = Assembly.GetExecutingAssembly().GetName().Name;
return source.ProjectsInOrder
.Where(p => p.ProjectType == SolutionProjectType.KnownToBeMSBuildFormat
&& p.ProjectName != currentAssembly)
.Select(p => new ProjectInfo
{
AssemblyName = p.ProjectName,
Path = p.AbsolutePath.Replace($"{p.ProjectName}.csproj", string.Empty)
});
}
}
}