public void Test_StartInfoParsing() { FileInfo instructions = new FileInfo(@"C:\An app\Updates\3.2\Instructions.xml"); FileInfo updater = new FileInfo(@"C:\An app\Updates\Updater.exe"); ProcessStartInfo startInfo = StartInfoCreator.CreateStartInfo(instructions, updater); Assert.AreEqual(@"C:\An app\Updates\Updater.exe", startInfo.FileName); UpdaterStartupSettings settings = CommandLineArgumentParser.GetSettings(CommandLineToArgs(startInfo.Arguments)); Assert.AreEqual(@"C:\An app\Updates\3.2\Instructions.xml", settings.InstructionsFile.FullName); }
public void TriggerUpdate(UpdaterStartupSettings settings, UpdateInstructions instructions) { string packagePath = this.GetProperPackagePath(instructions); if (packagePath != null && File.Exists(packagePath)) { FileInfo package = new FileInfo(packagePath); FileInfo executable = this.GetExecutablePackage(package); Console.WriteLine($"Launching package {executable.FullName}."); Process.Start(executable.FullName); } else { Console.WriteLine($"Failed to find package from {settings.InstructionsFile}"); Console.ReadKey(); } }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("This app has to be run with proper arguments."); Console.ReadKey(); return; } UpdaterStartupSettings settings = CommandLineArgumentParser.GetSettings(args); UpdateInstructions instructions = UpdateInstructionsReader.Read(settings.InstructionsFile); if (instructions != null) { Console.WriteLine($"Read update instructions from {settings.InstructionsFile}"); var worker = new PackageUpdaterWorker(); worker.TriggerUpdate(settings, instructions); } else { Console.WriteLine($"Failed to perform update based on instructions: {settings.InstructionsFile}"); } }