예제 #1
0
        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();
            }
        }
예제 #2
0
        public void Test_Worker_EnsureProperPackageIsPicked()
        {
            List <UpdatePackageData> packages = new List <UpdatePackageData>
            {
                new UpdatePackageData   {
                    Version = "1.2", FileName = "MyPackageBasedApp Updates v. 1.2.zip"
                }
                , new UpdatePackageData {
                    Version = "1.1.2", FileName = "MyPackageBasedApp Updates v. 1.1.2.zip"
                }
                , new UpdatePackageData {
                    Version = "1.1.3", FileName = "MyPackageBasedApp Updates v. 1.1.3.zip"
                }
            };

            packages.ForEach(x => x.StoredFilePath = Locator.Static.BuildUpdatePackagePath(this.Update12Folder, x).FullName);


            Tuple <XDocument, FileInfo> tuple = UpdateInstructionCreator.CreateXDoc(packages
                                                                                    , new ProgramInfo {
                PrimaryAssembly = new AssemblyInfo {
                    Location = @"C:\AppFolder\MyApp.exe"
                }
            }, "Program Display Name");
            XDocument xDoc = tuple.Item1;
            FileInfo  file = tuple.Item2;

            Assert.AreEqual($@"{this.Update12Folder.FullName}\UpdateInstructions.xml", file.FullName);

            UpdateInstructions instructions = UpdateInstructionsReader.DeserializeDocument(xDoc);

            Assert.AreEqual("Program Display Name", instructions.ProgramName);
            Assert.That(() => instructions.Packages.First().Version, Is.EqualTo("1.1.2"));
            Assert.That(() => instructions.Packages.Last().Version, Is.EqualTo("1.2"));
            var    worker   = new PackageUpdaterWorker();
            string expected = worker.GetProperPackagePath(instructions);

            Assert.That(expected, Is.EqualTo($@"{this.Update12Folder.FullName}\1.2\MyPackageBasedApp Updates v. 1.2.zip"));
        }
예제 #3
0
        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}");
            }
        }
예제 #4
0
        internal string GetProperPackagePath(UpdateInstructions instructions)
        {
            string packagePath = instructions.Packages.OrderByDescending(x => x.Version, new TelimenaVersionStringComparer()).FirstOrDefault()?.Path;

            return(packagePath);
        }