Ejemplo n.º 1
0
        public void ApplyReleasesWithOneReleaseFile()
        {
            string tempDir;

            using (Utility.WithTempDirectory(out tempDir)) {
                string packagesDir = Path.Combine(tempDir, "theApp", "packages");
                Directory.CreateDirectory(packagesDir);

                new[] {
                    "Squirrel.Core.1.0.0.0-full.nupkg",
                    "Squirrel.Core.1.1.0.0-full.nupkg",
                }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));

                var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader());

                var baseEntry       = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.0.0.0-full.nupkg"));
                var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));

                var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir, FrameworkVersion.Net40);
                updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue();

                using (fixture) {
                    var progress = new ReplaySubject <int>();
                    fixture.ApplyReleases(updateInfo, progress).First();
                    this.Log().Info("Progress: [{0}]", String.Join(",", progress));

                    progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue();
                    progress.Last().ShouldEqual(100);
                }

                var filesToFind = new[] {
                    new { Name = "NLog.dll", Version = new Version("2.0.0.0") },
                    new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") },
                    new { Name = Path.Combine("sub", "Ionic.Zip.dll"), Version = new Version("1.9.1.8") },
                };

                filesToFind.ForEach(x => {
                    var path = Path.Combine(tempDir, "theApp", "app-1.1.0.0", x.Name);
                    this.Log().Info("Looking for {0}", path);
                    File.Exists(path).ShouldBeTrue();

                    var vi      = FileVersionInfo.GetVersionInfo(path);
                    var verInfo = new Version(vi.FileVersion ?? "1.0.0.0");
                    x.Version.ShouldEqual(verInfo);
                });
            }
        }
Ejemplo n.º 2
0
        public ReleaseEntry GetReleaseEntry(string sourceDirectory)
        {
            var releasesPath = Path.Combine(sourceDirectory, "RELEASES");

            if (!File.Exists(releasesPath))
            {
                this.Log().Info("RELEASES doesn't exist, creating it at " + releasesPath);
                var nupkgs = (new DirectoryInfo(sourceDirectory)).GetFiles()
                             .Where(x => x.Name.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase))
                             .Select(x => ReleaseEntry.GenerateFromFile(x.FullName));

                ReleaseEntry.WriteReleaseFile(nupkgs, releasesPath);
            }

            return(ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasesPath, Encoding.UTF8))
                   .First());
        }
Ejemplo n.º 3
0
        static int Main(string[] args)
        {
#if DEBUG
            Debugger.Launch();
#endif

            var optParams = ParseCommands.ParseOptions(args);
            if (optParams == null)
            {
                return(-1);
            }

            var targetDir  = optParams["target"];
            var package    = new ReleasePackage(optParams["input"]);
            var targetFile = Path.Combine(targetDir, package.SuggestedReleaseFileName);

            var fullRelease = package.CreateReleasePackage(targetFile,
                                                           optParams["pkgdir"] != "" ? optParams["pkgdir"] : null,
                                                           input => (new Markdown()).Transform(input));

            Console.WriteLine("{0};", fullRelease);

            var releaseFile = Path.Combine(targetDir, "RELEASES");
            if (File.Exists(releaseFile))
            {
                var releasesText   = File.ReadAllText(releaseFile, Encoding.UTF8);
                var releaseEntries = ReleaseEntry.ParseReleaseFile(releasesText);

                var previousFullRelease = ReleaseEntry.GetPreviousRelease(releaseEntries, package, targetDir);

                if (previousFullRelease != null &&
                    File.Exists(previousFullRelease.ReleasePackageFile))
                {
                    var deltaFile = Path.Combine(targetDir, package.SuggestedReleaseFileName.Replace("full", "delta"));
                    Console.WriteLine("{0}; {1}", previousFullRelease.InputPackageFile, deltaFile);

                    var deltaBuilder = new DeltaPackageBuilder();
                    deltaBuilder.CreateDeltaPackage(previousFullRelease, package, deltaFile);
                }
            }

            ReleaseEntry.BuildReleasesFile(targetDir);

            return(0);
        }
Ejemplo n.º 4
0
        static int Main(string[] args)
        {
            var optParams = parseOptions(args);

            if (optParams == null)
            {
                return(-1);
            }

            var targetDir  = optParams["target"];
            var package    = new ReleasePackage(optParams["input"]);
            var targetFile = Path.Combine(targetDir, package.SuggestedReleaseFileName);

            var fullRelease = package.CreateReleasePackage(targetFile,
                                                           optParams["pkgdir"] != "" ? optParams["pkgdir"] : null,
                                                           input => (new Markdown()).Transform(input));

            var releaseFile = Path.Combine(targetDir, "RELEASES");

            if (File.Exists(releaseFile))
            {
                var releaseEntries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releaseFile, Encoding.UTF8));

                var latestFullRelease = releaseEntries
                                        .Where(x => x.IsDelta == false)
                                        .MaxBy(x => x.Version)
                                        .Select(x => new ReleasePackage(Path.Combine(targetDir, x.Filename), true))
                                        .FirstOrDefault();

                var deltaFile = Path.Combine(targetDir, package.SuggestedReleaseFileName.Replace("full", "delta"));
                Console.WriteLine("{0} {1}", latestFullRelease.InputPackageFile, deltaFile);

                var deltaBuilder = new DeltaPackageBuilder();
                deltaBuilder.CreateDeltaPackage(package, latestFullRelease, deltaFile);
            }

            ReleaseEntry.BuildReleasesFile(targetDir);

            Console.WriteLine(fullRelease);
            return(0);
        }
Ejemplo n.º 5
0
        private async void appStarter_Shown(object sender, EventArgs e)
        {
            this.Text = "WorkPermit v." + System.Windows.Forms.Application.ProductVersion;
#if (DEBUG == false)
            ReleaseEntry release = null;
            string       path    = string.Empty;
            if (Directory.Exists(Static.Secrets.SquirrelAbsoluteUpdatePath))
            {
                path = Static.Secrets.SquirrelAbsoluteUpdatePath;
            }
            else if (Directory.Exists(Static.Secrets.SquirrelUpdatePath))
            {
                path = Static.Secrets.SquirrelUpdatePath;
            }
            if (!string.IsNullOrWhiteSpace(path))
            {
                using (var mgr = new UpdateManager(path))
                {
                    //SquirrelAwareApp.HandleEvents(
                    //onInitialInstall: v =>
                    //{
                    //    mgr.CreateShortcutForThisExe();
                    //    mgr.CreateRunAtWindowsStartupRegistry();
                    //},
                    //onAppUninstall: v =>
                    //{
                    //    mgr.RemoveShortcutForThisExe();
                    //    mgr.RemoveRunAtWindowsStartupRegistry();
                    //});
                    release = await mgr.UpdateApp();
                }
                if (release != null)
                {
                    MessageBox.Show("Aplikacja została zaktualizowana do nowszej wersji. Naciśnij OK aby zrestartować aplikację", "Aktualizacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //force app restart
                    UpdateManager.RestartApp();
                }
            }
#endif
        }
        public ReleaseEntryViewModel(ReleaseEntry model)
        {
            this.Model = model;
            Enabled = true;

            Name = model.Filename.Split('-')[0];
            VersionString = String.Format("{0} {1}", Name, model.Version);

            this.WhenAnyValue(x => x.Enabled)
                .Where(x => x == false)
                .Subscribe(x => CurrentAction = ReleaseEntryActions.None);

            ApplyThisRelease = ReactiveCommand.CreateAsyncTask(async _ => {
            });
        }