file-folder-helper/Helpers/HelperILMerge.cs
Mike Phares 5fe51ef645 nuget bump
2023-11-02
2023-11-08
net8.0
editorconfig
NuGet NuSpec
Kanban
2023-11-14 07:54:34 -07:00

44 lines
1.9 KiB
C#

using System.Diagnostics;
using System.Text;
namespace File_Folder_Helper.Helpers;
internal static class HelperILMerge
{
internal static void ILMerge(string workingDirectory)
{
bool result;
ProcessStartInfo processStartInfo;
StringBuilder stringBuilder = new();
string[] successChecks = ["success"];
string[] errorChecks = ["Error", "Conflict", "error:"];
FileInfo ilMerge = new("C:/Users/phares/AppData/Local/IFXApps/ILMerge/ILMerge.exe");
string[] dllFiles = Directory.GetFiles(workingDirectory, "*.dll", SearchOption.TopDirectoryOnly);
string errorFile = Path.Combine(workingDirectory, string.Concat(Path.GetFileName(workingDirectory), ".err"));
string primaryFile = Path.Combine(workingDirectory, string.Concat(Path.GetFileName(workingDirectory), ".dll"));
FileInfo fileInfo = new(Path.Combine(workingDirectory, ilMerge.Name));
if (!fileInfo.Exists)
_ = ilMerge.CopyTo(fileInfo.FullName);
if (fileInfo.Exists && ilMerge.LastWriteTime != fileInfo.LastWriteTime)
_ = ilMerge.CopyTo(fileInfo.FullName, overwrite: true);
_ = stringBuilder.Append("/allowDup /target:library /out:\"").Append(Path.GetFileNameWithoutExtension(primaryFile)).Append(".all.dll\" ");
foreach (string dllFile in dllFiles)
{
if (dllFile == primaryFile)
continue;
_ = stringBuilder.Append('"').Append(Path.GetFileName(dllFile)).Append("\" ");
}
processStartInfo = new ProcessStartInfo(fileInfo.FullName, stringBuilder.ToString())
{
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
WorkingDirectory = workingDirectory,
};
result = HelperStart.Start(errorChecks, successChecks, processStartInfo, errorFile);
if (result)
{ }
}
}