using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; //using Microsoft.Tools.WindowsInstallerXml; using System.Xml; using System.Diagnostics; using System.Configuration; namespace Builder { class Program { private static string runBatFile(string filename) { ProcessStartInfo info = new ProcessStartInfo(filename); info.WorkingDirectory = (new FileInfo(filename)).Directory.FullName; info.UseShellExecute = false; info.RedirectStandardOutput = true; StringBuilder builder = new StringBuilder(); using(Process process = Process.Start(info)) { builder.Append(process.StandardOutput.ReadToEnd()); process.WaitForExit(); builder.Append(process.StandardOutput.ReadToEnd()); } return builder.ToString(); } static void Main(string[] args) { try { string WIXPATH = ConfigurationManager.AppSettings["WiXPath"]; if(args.Length < 1) throw new ApplicationException("You should specify project name first"); string path = args[0]; if(!Directory.Exists(path)) throw new ApplicationException("Directory doesn't exists"); string fullPath = new DirectoryInfo(path).FullName; fullPath += Path.DirectorySeparatorChar; string target = "release"; string targetId = "1"; if(args.Length > 1) { switch(args[1].ToLower()) { case "release": target = "release"; targetId = "1"; break; case "debug": target = "debug"; targetId = "2"; break; default: throw new ApplicationException("Wrong target"); } } string sourceFile = fullPath + "product.wxs"; if(!File.Exists(sourceFile)) throw new ApplicationException("No wxs file could be found"); string targetFile = fullPath + "product.wixobj"; string wixPdbFile = fullPath + "product-" + target + ".wixpdb"; string outputFile = fullPath + "product-" + target + ".msi"; string prebuildCommands = fullPath + "prebuild.bat"; string postbuildCommands = fullPath + "postbuild.bat"; string buildNumberFile = fullPath + "build.txt"; if(File.Exists(prebuildCommands)) { Console.WriteLine(">prebuild"); Console.WriteLine(runBatFile(prebuildCommands)); Console.WriteLine("