Example #1
0
        protected override IWixMainEntity CreateMainEntity()
        {
            WixProduct product = new WixProduct();

              // Создаем предопределенные элементы. Это общие элементы для
              // всех инсталляторов (для серверной и клиентской частей).
              // При построении msi данные секции уже должны быть в файлах wxs с
              // заполненными атрибутами.

              // Корневой элемент с типом WixFeatureElement создаст сам WixProduct.
              // Заполняем свойствами корневую Feature.
              product.RootElement.Id = "RootFeature";

              WixFeatureElement commonFeature = new WixFeatureElement();
              commonFeature.Id = "CommonFeature";
              commonFeature.Predefinition();
              product.RootElement.Items.Add(commonFeature);

              WixComponentElement component;

              component = new WixComponentElement();
              component.Id = "ProgramMenuFamilyDirComponent";
              component.Predefinition();
              commonFeature.Items.Add(component);

              component = new WixComponentElement();
              component.Id = "ProgramMenuProductDirComponent";
              component.Predefinition();
              commonFeature.Items.Add(component);

              component = new WixComponentElement();
              component.Id = "ReinstallComponent";
              component.Predefinition();
              commonFeature.Items.Add(component);

              return product;
        }
Example #2
0
        private void CreateProductUpdateInfos()
        {
            WixProduct oldProduct;
              WixProduct newProduct;

              // Создадим продукт старой версии.
              // Продукт oldProduct содержит:
              //   Feature1
              //      Component11
              //      Component12
              //   Feature2
              //      Component21
              oldProduct = new WixProduct();
              WixFeatureElement feature = new WixFeatureElement { Id = "Feature1" };
              feature.Items.Add(new WixComponentElement { Id = "Component11" });
              feature.Items.Add(new WixComponentElement { Id = "Component12" });
              oldProduct.RootElement.Items.Add(feature);
              feature = new WixFeatureElement { Id = "Feature2" };
              feature.Items.Add(new WixComponentElement { Id = "Component21" });
              oldProduct.RootElement.Items.Add(feature);

              // Сохраним его и загрузим в продукт новой версии.
              // Изменим уже существующий и добавим один компонент.
              // Продукт newProduct содержит:
              //   Feature1
              //      Component11
              //      Component12 (изменён)
              //        File121
              //   Feature2
              //      Component21
              //      Component22 (добавлен)
              XmlSaverLoader.Save(oldProduct, "Product.xml");
              newProduct = XmlSaverLoader.Load<WixProduct>("Product.xml");
              newProduct.RootElement.Items[0].Items[1].Items.Add(new WixFileElement { Id = "File121", FileName = exeFile });
              newProduct.RootElement.Items[1].Items.Add(new WixComponentElement { Id = "Component22" });

              // Удалим файл, больше не нужен.
              File.Delete("Product.xml");

              WixProductUpdateInfo oldInfo = WixProductUpdateInfo.Create(oldProduct, oldWixout, "");
              WixProductUpdateInfo newInfo = WixProductUpdateInfo.Create(newProduct, newWixout, "");

              // При создании wixout удалится.
              oldInfo.Save(oldUpdzip, true);
              newInfo.Save(newUpdzip, true);
        }
        /// <summary>
        /// Создает объект. Фабричный метод.
        /// </summary>
        public static WixProductUpdateInfo Create(WixProduct product, string wixoutFileName, string baseDirectory)
        {
            WixMD5ElementHash[] hashes = product.RootElement.Items.Descendants().Select(v => v.GetMD5(baseDirectory)).ToArray();

              return new WixProductUpdateInfo()
              {
            Id = product.Id,
            Name = product.Name,
            Manufacturer = product.Manufacturer,
            Version = product.Version,
            WixoutFileName = wixoutFileName,
            Hashes = hashes
              };
        }