Skip to content

Commit c8049ab

Browse files
committed
added SolutionFinder
1 parent 8b800a9 commit c8049ab

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
6+
namespace Incrementalist.FileSystem
7+
{
8+
/// <summary>
9+
/// Used to look for .sln files in a given directory.
10+
/// </summary>
11+
public static class SolutionFinder
12+
{
13+
/// <summary>
14+
/// The default filter used to look for solutions in a given folder.
15+
/// </summary>
16+
public const string DefaultSolutionFilter = "*.sln";
17+
18+
/// <summary>
19+
/// Enumerate all of the MSBuild solution files in a given folder.
20+
/// </summary>
21+
/// <param name="folderPath">The top level path to search.</param>
22+
/// <param name="searchFilter">Optional. A wildcard filter in the form of "*.sln".</param>
23+
/// <param name="searchOption">Optional. Specifies whether to recurse sub-directories or not.</param>
24+
/// <returns>If any solutions are found, will return an enumerable list of them in order in which they are discovered.</returns>
25+
public static IEnumerable<string> GetSolutions(string folderPath, string searchFilter = null, SearchOption? searchOption = null)
26+
{
27+
if (string.IsNullOrEmpty(searchFilter))
28+
{
29+
return Directory.EnumerateFileSystemEntries(folderPath, DefaultSolutionFilter, searchOption ?? SearchOption.AllDirectories);
30+
}
31+
32+
return Directory.EnumerateFileSystemEntries(folderPath, searchFilter, searchOption ?? SearchOption.AllDirectories);
33+
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)