private void LoadInformation()
        {
            Manifests.Clear();

            try
            {
                var manifests = _manifestService.GetManifestNames();

                foreach (var manifestName in manifests)
                {
                    var manifest = _manifestService.GetManifest(manifestName);

                    Manifests.Add(new ManifestViewModel
                    {
                        Name           = manifestName,
                        DomainOverride = manifest.OverrideDomain,
                        DomainOverrideChangedCommand = new RelayCommand(param => _manifestService.SetActiveManifestDomain(param != null ? param.ToString() : string.Empty))
                    });
                }

                var selectedManifestName = _manifestService.GetActiveManifestName();
                SelectedManifest = Manifests.FirstOrDefault(m => m.Name == selectedManifestName);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error Loading Manifest List", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
        static void CreateBuild(BuilderOptions options)
        {
            Console.WriteLine("Creating Build for " + options.UpdateChannel.ToString() + " version " + options.Version);


            List <Manifest> Manifests;

            //Get the Manifests if the file exists.  If it doesn't, create it
            if (!File.Exists(options.Manifest))
            {
                Console.WriteLine("Manifest file does not exist, creating Manifests");
                CreateDefaultManifests(options);
            }


            Manifests = JsonConvert.DeserializeObject <List <Manifest> >(File.ReadAllText(options.Manifest));


            //Get the update channel we are building for
            Manifest man = Manifests.FirstOrDefault(x => x.Channel == options.UpdateChannel.ToString());

            if (man == null)
            {
                Console.WriteLine("Error: Cannot find the manifest for " + options.Manifest + "!  Aborting.");
                Environment.Exit(0);
            }

            //Get the list of builds
            string buildListFilename = options.UpdateChannel.ToString() + "BuildList.txt";

            List <Build> builds = JsonConvert.DeserializeObject <List <Build> >(File.ReadAllText(buildListFilename));



            Console.WriteLine("Creating build information");
            //Create the build
            Build b = new Build()
            {
                FileName    = Path.GetFileName(options.BuildFile),
                DownloadURL = options.URL + options.UpdateChannel.ToString() + "/",
                Notes       = options.UpdateNotes,
                DetailURL   = options.DetailedNotesURL,
                Version     = options.Version,
                Date        = DateTime.Now,
            };


            Console.WriteLine("Writing Build");
            //Copy the file to the output directory
            string outputDir = options.OutputPath + "/" + options.UpdateChannel.ToString() + "/";

            Directory.CreateDirectory(options.OutputPath);
            Directory.CreateDirectory(outputDir);

            //Create the version file
            UpdaterLib.Version version = new UpdaterLib.Version()
            {
                Name      = b.Version,
                Channel   = options.UpdateChannel,
                Origin    = b.DownloadURL,
                Notes     = b.Notes,
                BuildDate = b.Date,
            };

            //And insert it into the output
            Console.WriteLine("Inserting version.txt");
            using (ZipFile z = new ZipFile(options.BuildFile))
            {
                z.AddEntry("version.txt", JsonConvert.SerializeObject(version));
                string updaterexe = Assembly.GetExecutingAssembly().Location;
                z.AddFile(updaterexe, "");
                z.Save();
            }

            Console.WriteLine("Computing Sha Hash of the build");
            //Create the sha hash
            string hash = "";

            using (FileStream stream = File.OpenRead(options.BuildFile))
            {
                SHA256Managed sha = new SHA256Managed();
                byte[]        h   = sha.ComputeHash(stream);
                hash = BitConverter.ToString(h).Replace("-", String.Empty);
            }

            b.Sha = hash;
            builds.Add(b);

            Console.WriteLine("Deploying Build");
            File.Copy(options.BuildFile, outputDir + Path.GetFileName(options.BuildFile), true);

            Console.WriteLine("Writing Buildfile");
            //Write the builds file
            File.WriteAllText(buildListFilename, JsonConvert.SerializeObject(builds));
            File.WriteAllText(options.OutputPath + "/" + buildListFilename, JsonConvert.SerializeObject(builds));

            //Update the manifest
            man.LastUpdate    = b.Date;
            man.LatestVersion = b.Version;

            Console.WriteLine("Writing Manifest");
            //Write the manifests
            File.WriteAllText(options.Manifest, JsonConvert.SerializeObject(Manifests));
            File.WriteAllText(options.OutputPath + "/" + options.Manifest, JsonConvert.SerializeObject(Manifests));
        }