Esempio n. 1
0
        public void XmlSaverLoaderWixFeatureElementSaveAndLoad()
        {
            string fileName = "Test.xml";

              if (File.Exists(fileName))
            File.Delete(fileName);

              WixFeatureElement featureForSave = new WixFeatureElement();
              featureForSave.Id = "Id1";
              featureForSave.Title = "Title1";
              featureForSave.Description = "Description1";

              WixFeatureElement featureNested = new WixFeatureElement();
              featureNested.Id = "Id2";
              featureNested.Title = "Title2";
              featureNested.Description = "Description2";

              featureForSave.Items.Add(featureNested);

              XmlSaverLoader.Save<WixFeatureElement>(featureForSave, fileName);

              Assert.IsTrue(File.Exists(fileName));

              WixFeatureElement featureForLoad = XmlSaverLoader.Load<WixFeatureElement>(fileName);

              if (File.Exists(fileName))
            File.Delete(fileName);

              Assert.AreEqual(featureForSave.Id, featureForLoad.Id);
              Assert.AreEqual(featureForSave.Title, featureForLoad.Title);
              Assert.AreEqual(featureForSave.Description, featureForLoad.Description);
        }
Esempio n. 2
0
        public void XmlSaverLoaderWixFeatureElementLoadWithTargetType()
        {
            string fileName = "Test.xml";

              if (File.Exists(fileName))
            File.Delete(fileName);

              try
              {
            WixFeatureElement actual = new WixFeatureElement();
            actual.Id = "Id1";

            XmlSaverLoader.Save<WixFeatureElement>(actual, fileName);

            // Укажем правильный тип.
            IWixElement expected = XmlSaverLoader.Load<IWixElement>(fileName, typeof(WixFeatureElement));

            Assert.IsInstanceOfType(expected, typeof(WixFeatureElement));
            Assert.AreEqual(((WixFeatureElement)expected).Id, actual.Id);

            // Укажем неправильный тип.
            // Должен быть выброс исключения.
            expected = XmlSaverLoader.Load<IWixElement>(fileName, typeof(object));
              }
              finally
              {
            if (File.Exists(fileName))
              File.Delete(fileName);
              }
        }
Esempio n. 3
0
        public void WixMD5WithChilds()
        {
            WixFeatureElement featureOne = new WixFeatureElement();
              featureOne.Items.Add(new WixComponentElement());
              XmlSaverLoader.Save(featureOne, "Test.xml");

              WixFeatureElement featureTwo = XmlSaverLoader.Load<WixFeatureElement>("Test.xml");
              featureTwo.Items.Add(new WixComponentElement());

              WixMD5ElementHash hashOne = featureOne.GetMD5();
              WixMD5ElementHash hashTwo = featureTwo.GetMD5();

              Assert.AreNotEqual(hashOne.Hash, hashTwo.Hash);

              File.Delete("Test.xml");
        }
Esempio n. 4
0
    public WixProduct()
    {
      Id = Guid.NewGuid();
      UpgradeCode = Guid.NewGuid();
      Name = string.Empty;
      Manufacturer = string.Empty;
      Version = new AppVersion();
      PackageDescription = string.Empty;
      PackageComments = string.Empty;
      InstallLocationFamilyFolder = string.Empty;
      InstallLocationProductFolder = string.Empty;

      // Уникальные идентификаторы для компонент деинсталляции директорий
      // семейства продукта, самого продукта и ярлыка переустановки из меню пуск.
      // Должны быть одинаковые в пределах продукта основной версии.
      // В GUI не показываем, для пользователя не нужны.
      ProgramMenuFamilyDirComponentGuid = Guid.NewGuid();
      ProgramMenuProductDirComponentGuid = Guid.NewGuid();
      ProgramMenuReinstallComponentGuid = Guid.NewGuid();

      RootElement = new WixFeatureElement();
    }
Esempio n. 5
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);
        }
Esempio n. 6
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;
        }
Esempio n. 7
0
 public void MsiModelSelectedItemInitializedWrong()
 {
     BuilderModel model = new MsiModel();
       model.Items.Add(new WixFeatureElement());
       IWixElement element = new WixFeatureElement();
       model.SelectedItem = element;
       Assert.Fail();
 }
Esempio n. 8
0
        public void MsiModelSelectedItemInitializedSuccessful()
        {
            BuilderModel model = new MsiModel();
              IWixElement element = new WixFeatureElement();
              model.Items.Add(element);
              model.SelectedItem = element;
              Assert.AreEqual(element, model.SelectedItem);

              element = new WixFeatureElement();
              model.Items[0].Items.Add(element);
              model.SelectedItem = element;
              Assert.AreEqual(element, model.SelectedItem);
        }