using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Windows.Forms; using System.Diagnostics; namespace wix { class Program { static int no = 0; static StreamWriter sw; static List components = new List(); static string mainexeid = ""; static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Bad Directory"); return; } string path = args[0]; string file = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar+ "installer.wxs"; sw = new StreamWriter(file); header(); sw.WriteLine(""); sw.WriteLine(@" "); //sw.WriteLine(""); dodirectory(path, 0); footer(); sw.Close(); /* System.Diagnostics.Process P = new System.Diagnostics.Process(); P.StartInfo.FileName = "cmd.exe"; P.StartInfo.Arguments = " /c \"" + Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "installer.bat\""; P.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath); P.Start(); */ //Console.ReadLine(); } static void header() { string newid = System.Guid.NewGuid().ToString(); newid = "{625389D7-EB3C-4d77-A5F6-A285CF99437D}"; StreamReader sr = new StreamReader(File.OpenRead("../Properties/AssemblyInfo.cs")); string version = "0"; while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.Contains("AssemblyFileVersion")) { string[] items = line.Split(new char[] { '"' },StringSplitOptions.RemoveEmptyEntries); version = items[1]; break; } } sr.Close(); string data = @" "; sw.WriteLine(data); } static void footer() { string data = @" "; sw.WriteLine(data); foreach (string comp in components) { sw.WriteLine(@""); } data = @" WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed "; sw.WriteLine(data); } static void dodirectory(string path, int level = 1) { string[] dirs = Directory.GetDirectories(path); if (level != 0) sw.WriteLine(""); string[] files = Directory.GetFiles(path); sw.WriteLine(""); components.Add("_comp"+no); foreach (string filepath in files) { if (filepath.EndsWith("config.xml") || filepath.Contains("ArdupilotPlanner.log")) continue; no++; sw.WriteLine(""); if (filepath.EndsWith("ArdupilotMegaPlanner.exe")) { mainexeid = "_" + no; } } sw.WriteLine(""); foreach (string dir in dirs) { if (dir.EndsWith("gmapcache") || dir.EndsWith("srtm")) continue; dodirectory(dir); } if (level != 0) sw.WriteLine(""); } static string fixname(string name) { name = name.Replace("-", "_"); name = name.Replace(" ", "_"); name = name.Replace(" ", "_"); return name; } } }