create helper classes

This commit is contained in:
Matthew Parker [SSW]
2024-01-21 14:59:19 +10:00
parent 3f5905349d
commit 22af01dc48
16 changed files with 225 additions and 215 deletions

View File

@@ -0,0 +1,24 @@
using Microsoft.Build.Construction;
namespace DotNetSolutionTools.Core.Common;
public static class CsprojHelper
{
public static string[] RetrieveAllCSharpProjectFullPathsFromFolder(string solutionFolderPath)
{
// if solutionFolderPath does not end with a slash, add one
if (solutionFolderPath[^1] != Path.DirectorySeparatorChar)
{
solutionFolderPath += Path.DirectorySeparatorChar;
}
var csprojList = Directory.GetFiles(solutionFolderPath, "*.csproj", SearchOption.AllDirectories);
return csprojList;
}
public static string[] RetrieveAllCSharpProjectFullPathsFromSolution(SolutionFile solution)
{
var result = SlnHelper.GetCSharpProjectObjectsFromSolutionFile(solution);
var csprojList = result.Select(x => x.FullPath).ToArray();
return csprojList;
}
}