예제 #1
0
        public static bool Check(ServerInformation serverInformation)
        {
            var appUpdater = new AppUpdaterBuilder("Orc.MediaSync.Client")
                                .SourceUpdatesFrom("http://nuget.offroadcode.com/")
                                .Build();

            // This will run the UpdateDatabase method if this is the first
            // time we have run the application after an update is installed.
            if (appUpdater.OldVersionExists)
            {
                appUpdater.RemoveOldVersionFiles();
            }

            Console.WriteLine("Current Version:"+appUpdater.CurrentVersion);
            Console.WriteLine("Checking for updates...");

            var updateCheck = appUpdater.CheckForUpdate();
            if (updateCheck.UpdateAvailable)
            {
                Console.WriteLine("Update found, updating to " + updateCheck.UpdatePackage.Version);
                var preparedUpdate = appUpdater.PrepareUpdate(updateCheck.UpdatePackage);
                var installedUpdate = appUpdater.ApplyPreparedUpdate(preparedUpdate);

                // Runs the new version of the application with the same command
                // line arguments that we were initially given.
                appUpdater.LaunchInstalledUpdate(installedUpdate);
                return false;
            }
            Console.WriteLine("No Updates available!");
            return true;
        }
예제 #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;
        }