-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDirectoryProcessor.cs
More file actions
50 lines (42 loc) · 1.54 KB
/
DirectoryProcessor.cs
File metadata and controls
50 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.IO;
using System.Diagnostics;
namespace Compiler
{
public class DirectoryProcessor
{
private const string CsProjFilePattern = "*.csproj";
public static void ProcessDirectory(string folderPath, Config config)
{
if (DirectoryProcessor.IsValidDirectory(folderPath))
{
DotNetCommandExecutor.RunDotNetPublish(folderPath, config); // Pass the config to the method.
}
else
{
Console.WriteLine("The specified path is not a valid directory or project is not valid");
}
}
public static void ProcessCurrentDirectory(Config config)
{
Console.WriteLine("Listing all folders in the current directory:");
string[] folders = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory);
if (!folders.Any())
{
Console.WriteLine("No folders found in the current directory.");
return;
}
Parallel.ForEach(folders, folder =>
{
if (IsValidDirectory(folder))
{
DotNetCommandExecutor.RunDotNetPublish(folder, config); // Pass the config to the method.
}
});
}
public static bool IsValidDirectory(string folderPath)
{
return Directory.Exists(folderPath) && Directory.EnumerateFiles(folderPath, CsProjFilePattern, SearchOption.TopDirectoryOnly).Any();
}
}
}