示例#1
0
        static void Main(string[] args)
        {
            var appUpdater = new AppUpdaterBuilder("NuSelfUpdate.Sample")
                             .SourceUpdatesFrom(FullPath("packages"))
                             .Build();

            Observable.Interval(TimeSpan.FromSeconds(5), Scheduler.TaskPool)
            .Select(_ => appUpdater.CheckForUpdate())
            .Do(Console.WriteLine)
            .Where(check => check.UpdateAvailable)
            .Take(1)     // We only want to prepare the update once
            .Select(uc => appUpdater.PrepareUpdate(uc.UpdatePackage))
            .Do(Console.WriteLine)
            .Select(appUpdater.ApplyPreparedUpdate)
            .Do(Console.WriteLine)
            .Select(appUpdater.LaunchInstalledUpdate)
            .Subscribe(Quit);

            Console.WriteLine("NuSelfUpdate.Sample - version: " + appUpdater.CurrentVersion);
            Console.WriteLine("Sample, will check for updates every 5 seconds.");
            Console.WriteLine("Drop a new package version into the packages\\NuSelfUpdate.Sample.<version> folder to update.");

            PrintCommandLineArgs();

            Console.WriteLine();
            Console.WriteLine("Press enter to exit");

            Console.ReadLine();
        }
示例#2
0
        /// <summary>
        /// Runs the command
        /// </summary>
        /// <param name="suite">The current suite model the command is applied to</param>
        /// <param name="parameters">Parameters given to the command (in unprocessed form)</param>
        /// <returns>Returns <c>true</c> if the command succeeded</returns>
        public bool Run(Suite suite, string[] parameters)
        {
            var fileSystem = new ExtendedPhysicalFileSystem(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
            var updater    = new AppUpdaterBuilder(NUGET_PACKAGE_ID)
                             .FileSystemAccessedThrough(fileSystem)
                             .Build();

            output.Message("Checking for updates (current version: {0})...", updater.CurrentVersion);
            var check = updater.CheckForUpdate();

            if (check.UpdateAvailable)
            {
                output.Message("..found update: {0}", check.UpdatePackage.Version);
                output.Message("..preparing update..");
                var preparedUpdate = PrepareUpdate(updater, fileSystem, check.UpdatePackage);

                output.Message("..applying update..");
                updater.ApplyPreparedUpdate(preparedUpdate);

                output.Message("Update completed.");
                output.Warning("You should rebuild your suites with the updated bari before using them!");
            }
            else
            {
                output.Message("No updates available.");
            }
            return(true);
        }
示例#3
0
        static void Main(string[] args)
        {
            var appUpdater = new AppUpdaterBuilder("NuSelfUpdate.Sample")
                .SourceUpdatesFrom(FullPath("packages"))
                .Build();

            Observable.Interval(TimeSpan.FromSeconds(5), Scheduler.TaskPool)
                .Select(_ => appUpdater.CheckForUpdate())
                .Do(Console.WriteLine)
                .Where(check => check.UpdateAvailable)
                .Take(1) // We only want to prepare the update once
                .Select(uc => appUpdater.PrepareUpdate(uc.UpdatePackage))
                .Do(Console.WriteLine)
                .Select(appUpdater.ApplyPreparedUpdate)
                .Do(Console.WriteLine)
                .Select(appUpdater.LaunchInstalledUpdate)
                .Subscribe(Quit);

            Console.WriteLine("NuSelfUpdate.Sample - version: " + appUpdater.CurrentVersion);
            Console.WriteLine("Sample, will check for updates every 5 seconds.");
            Console.WriteLine("Drop a new package version into the packages\\NuSelfUpdate.Sample.<version> folder to update.");

            PrintCommandLineArgs();

            Console.WriteLine();
            Console.WriteLine("Press enter to exit");

            Console.ReadLine();
        }