protected override string GenerateCommandLineCommands() { List <string> argv = new List <string>(); argv.Add("-out:" + JarFile.GetMetadata("FullPath")); argv.AddRange(Namespaces.Select(x => "-namespace:" + x)); argv.AddRange(InputAssemblies.Select(x => x.GetMetadata("FullPath"))); return(string.Join(" ", argv.Select(x => $"\"{x}\""))); }
public override bool Execute() { if (string.IsNullOrEmpty(OutputFileName)) { OutputFileName = InputAssemblies[0]; } if (!Directory.Exists(Path.GetDirectoryName(OutputFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(OutputFileName)); } var cleanupExcludeFile = false; if (InternalizeExclude != null && InternalizeExclude.Length > 0) { InternalizeExcludeFile = Path.GetTempFileName(); File.WriteAllLines(InternalizeExcludeFile, InternalizeExclude); cleanupExcludeFile = true; } var ilmSearchPath = Path.GetFullPath(Path.Combine(Assembly.GetExecutingAssembly().Location, "..", "..")); var ilMergePath = Directory.GetFiles(ilmSearchPath, "ilmerge.exe", SearchOption.AllDirectories).Max(); var args = new StringBuilder(); if (SearchDirectories != null && SearchDirectories.Length > 0) { args.Append(string.Join("", SearchDirectories.Select(x => string.Format(@" /lib:""{0}""", x.TrimEnd('\\'))))); } if (Log) { args.Append(" /log"); } if (!string.IsNullOrWhiteSpace(InternalizeExcludeFile)) { args.AppendFormat(@" /internalize:""{0}""", InternalizeExcludeFile); } else if (Internalize) { args.Append(" /internalize"); } if (!string.IsNullOrWhiteSpace(TargetPlatform)) { args.AppendFormat(@" /targetplatform:{0}", TargetPlatform); } if (!string.IsNullOrWhiteSpace(TargetPlatformDir)) { args.AppendFormat(@",""{0}""", TargetPlatformDir); } if (WildCards) { args.Append(" /wildcards"); } args.AppendFormat(@" /out:""{0}""", OutputFileName); args.Append(string.Join("", InputAssemblies.Select(x => @" """ + x + @""""))); var ilMergeProc = new ProcessHostRedirect() { FileName = ilMergePath, Arguments = args.ToString().Trim() }; ilMergeProc.CommandLinePrefix = ""; ilMergeProc.OutputDataHandler = (dataType, line) => { LogLine(line); }; ilMergeProc.Execute(); if (cleanupExcludeFile) { File.Delete(InternalizeExcludeFile); } return(true); }