using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Tools
{
/// <summary>
/// 使用ILmerge合并Exe、Dll文件的帮助类
/// </summary>
public class ILmerge
{
/// <summary>
/// 得到合并Exe、Dll文件的ILmerge语句
/// </summary>
/// <param name="DllPath">Dll文件目录</param>
/// <param name="SourceExeFile">原exe文件全路径</param>
/// <param name="TargetExeFile">要生成的exe文件全路径</param>
/// <returns></returns>
public static string GetMergeExeCmd(string DllPath,string SourceExeFile,string TargetExeFile)
{
StringBuilder sb = new StringBuilder();
sb.Append("ILmerge /ndebug /target:winexe /out:");
sb.Append(TargetExeFile);
sb.Append(" /log ");
sb.Append(SourceExeFile);
string []dllFiles = Directory.GetFiles(@DllPath,"*.dll");
foreach (string dllFile in dllFiles)
{
sb.Append(" " + dllFile);
}
return sb.ToString();
}
/// <summary>
/// 得到合并Dll文件的ILmerge语句
/// </summary>
/// <param name="DllPath">Dll文件目录</param>
/// <param name="TargetDllFile">要生成的Dll文件全路径</param>
/// <returns></returns>
public static string GetMergeDllCmd(string DllPath, string TargetDllFile)
{
StringBuilder sb = new StringBuilder();
sb.Append("ILmerge /ndebug /target:dll /out:");
sb.Append(TargetDllFile);
sb.Append(" /log ");
string[] dllFiles = Directory.GetFiles(@DllPath,"*.dll");
foreach (string dllFile in dllFiles)
{
sb.Append(" " + dllFile);
}
return sb.ToString();
}
}
}