public void Init()
 {
     doc          = new WixDocument();
     doc.FileName = @"C:\Projects\Setup\Setup.wxs";
     doc.LoadXml(GetWixXml());
     component = (WixComponentElement)doc.SelectSingleNode("//w:Component", new WixNamespaceManager(doc.NameTable));
 }
Exemplo n.º 2
0
        public void SetUpFixture()
        {
            WixDocument doc = new WixDocument();

            doc.LoadXml(GetWixXml());
            id = WixComponentElement.GenerateIdFromFileName(doc, @"C:\Projects\My.Project\MyApp.exe");
        }
        public void ExeFileComponentId()
        {
            WixComponentElement component = new WixComponentElement(new WixDocument());
            string expectedId             = component.GenerateIdFromFileName("TestApplication.exe");

            Assert.AreEqual(expectedId, exeFileComponentElement.GetAttribute("Id"));
        }
        public void ReadmeFileComponentId()
        {
            WixComponentElement component = new WixComponentElement(new WixDocument());
            string expectedId             = component.GenerateIdFromFileName("readme.rtf");

            Assert.AreEqual(expectedId, readmeFileComponentElement.GetAttribute("Id"));
        }
        public void AddDirectoryWithHyphen()
        {
            view.SelectedElement = null;
            editor.AddDirectory(directory2);

            WixDirectoryElement directoryElement    = (WixDirectoryElement)editor.Document.GetRootDirectory().SelectSingleNode("w:Directory[@Name='a-app']", nsManager);
            WixComponentElement exeComponentElement = (WixComponentElement)directoryElement.SelectSingleNode("w:Component[w:File/@Name='MyApp.exe']", nsManager);

            Assert.AreEqual("A_appMyAppExe", exeComponentElement.Id);
        }
Exemplo n.º 6
0
        public void SetUpFixture()
        {
            WixDocument doc = new WixDocument();

            doc.LoadXml(GetWixXml());
            WixComponentElement wixComponent = new WixComponentElement(doc);

            wixComponent.GenerateUniqueIdFromFileName(@"C:\Projects\My.Project\MyApp.exe");
            id = wixComponent.Id;
        }
        public void Init()
        {
            base.InitFixture();
            editor.AddDirectory(directory);

            nsManager               = new WixNamespaceManager(editor.Document.NameTable);
            appDirectoryElement     = (WixDirectoryElement)editor.Document.GetRootDirectory().SelectSingleNode("w:Directory[@Name='MyApp']", nsManager);
            readmeComponentElement  = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component[w:File/@Name='readme.txt']", nsManager);
            licenseComponentElement = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component[w:File/@Name='license.txt']", nsManager);
            exeComponentElement     = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component[w:File/@Name='MyApp.exe']", nsManager);
        }
        public void SetUpFixture()
        {
            base.InitFixture();
            editor.AddDirectory(directory);

            WixNamespaceManager nsManager = new WixNamespaceManager(editor.Document.NameTable);

            appDirectoryElement          = (WixDirectoryElement)editor.Document.GetRootDirectory().FirstChild;
            myAppExeFileComponentElement = (WixComponentElement)appDirectoryElement.SelectSingleNode("w:Component", nsManager);
            myAppExeFileElement          = (WixFileElement)myAppExeFileComponentElement.LastChild;
            docsDirectoryElement         = (WixDirectoryElement)appDirectoryElement.SelectSingleNode("w:Directory[@Name='docs']", nsManager);
            srcDirectoryElement          = (WixDirectoryElement)appDirectoryElement.SelectSingleNode("w:Directory[@Name='src']", nsManager);
            cssDirectoryElement          = (docsDirectoryElement.GetDirectories())[0];
            readmeFileElement            = (WixFileElement)docsDirectoryElement.SelectSingleNode("w:Component/w:File[@Name='readme.txt']", nsManager);
        }
        void AddNewChildElementsToDirectory()
        {
            WixDirectoryRefElement dirRef          = document.GetRootDirectoryRef();
            WixDirectoryElement    programFilesDir = dirRef.FirstChild as WixDirectoryElement;

            WixDirectoryElement sharpDevelopDir = programFilesDir.AddDirectory("SharpDevelop");

            sharpDevelopDir.Id = "SharpDevelopFolder";

            WixComponentElement component = sharpDevelopDir.AddComponent("SharpDevelopExe");

            component.Guid = "guid";
            WixFileElement file = component.AddFile("SharpDevelop.exe");

            file.Source = @"..\..\bin\SharpDevelop.exe";
        }
Exemplo n.º 10
0
        public void SetUpFixture()
        {
            doc          = new WixDocument();
            doc.FileName = @"C:\Projects\Setup\Setup.wxs";
            doc.LoadXml(GetWixXml());
            WixDirectoryElement rootDirectory = doc.RootDirectory;

            WixDirectoryElement[] rootChildDirectories  = rootDirectory.GetDirectories();
            WixDirectoryElement   programFilesDirectory = rootChildDirectories[0];

            WixDirectoryElement[] programFilesChildDirectories = programFilesDirectory.GetDirectories();
            WixDirectoryElement   myAppDirectory = programFilesChildDirectories[0];

            WixComponentElement[] childComponents = myAppDirectory.GetComponents();
            WixComponentElement   coreComponent   = childComponents[0];

            files = coreComponent.GetFiles();
        }
Exemplo n.º 11
0
        protected override void AddNewChildElementsToDirectory()
        {
            WixDirectoryElement dir             = document.GetRootDirectory();
            WixDirectoryElement programFilesDir = dir.AddDirectory("ProgramFilesFolder");

            programFilesDir.SourceName = "PFiles";
            programFilesDir.RemoveAttribute("Name");

            WixDirectoryElement sharpDevelopDir = programFilesDir.AddDirectory("SharpDevelop");

            sharpDevelopDir.Id = "SharpDevelopFolder";

            WixComponentElement component = sharpDevelopDir.AddComponent("SharpDevelopExe");

            component.Guid = "guid";
            WixFileElement file = component.AddFile("SharpDevelop.exe");

            file.Source = @"..\..\bin\SharpDevelop.exe";
        }
Exemplo n.º 12
0
        public void WixMD5WithoutFile()
        {
            using (ShimsContext.Create())
              {
            // Компонент создает Guid сам, вмешаемся.
            System.Fakes.ShimGuid.NewGuid = () => { return Guid.Parse("53773F52-67A0-475E-8622-A2C57E7E6B7B"); };

            WixComponentElement componentOne = new WixComponentElement();
            WixMD5ElementHash hashOne = componentOne.GetMD5();

            Assert.AreEqual(componentOne.GetType().Name, hashOne.Type);
            Assert.AreEqual(componentOne.Id, hashOne.Id);
            Assert.IsNotNull(hashOne.Hash);
            // Должна быть длина 32 символа.
            Assert.AreEqual(32, hashOne.Hash.Length);
            Assert.AreEqual("2b0596edb4097b702f610cf86302233e", hashOne.Hash);
            Assert.IsNull(hashOne.Files);

            WixComponentElement componentTwo = new WixComponentElement();
            WixMD5ElementHash hashTwo = componentTwo.GetMD5();
            Assert.AreEqual(hashOne.Hash, hashTwo.Hash);
              }
        }
Exemplo n.º 13
0
        private void ProcessingTemplateSimpleComponent(IBuildContext context, CancellationTokenSource cts, XElement xmlWix, WixComponentElement component,
      IDictionary<string, DirectoryInfo> directories)
        {
            // Добавляем файлы. В WIX в одном компоненте может быть несколько файлов, но
              // мы будем использовать для каждого файла отдельный компонент. Так не будет
              // проблем с директориями, потому что пользователь может указать для
              // каждого файла разные директории установки. И что более важно, согласно ТЗ,
              // будем в дальнейшем формировать обновления для каждого файла.
              foreach (WixFileElement file in component.Items.OfType<WixFileElement>())
              {
            XElement xmlFile;
            // Словарь для иконок.
            Dictionary<string, string> icons = new Dictionary<string, string>();
            string installDirectoryId = directories[file.InstallDirectory].Id;
            string pathToFile = Path.Combine(context.SourceStoreDirectory, file.InstallDirectory, file.FileName);

            XElement xmlDirectory = new XElement(XmlNameSpaceWIX + "DirectoryRef",
              new XAttribute("Id", installDirectoryId),
              new XElement(XmlNameSpaceWIX + "Component",
            new XAttribute("Id", component.Id),
            new XAttribute("Guid", component.Guid),
            xmlFile = new XElement(XmlNameSpaceWIX + "File",
              new XAttribute("Id", file.Id),
              new XAttribute("Name", file.FileName),
              new XAttribute("Source", pathToFile),
              new XAttribute("KeyPath", "yes"))));

            // Если у файла указаны ярлыки, добавим.
            foreach (WixShortcutElement shortcut in file.Items.OfType<WixShortcutElement>())
            {
              // Обязательные атрибуты.
              XElement xmlShortcut = new XElement(XmlNameSpaceWIX + "Shortcut",
            new XAttribute("Id", shortcut.Id),
            new XAttribute("Name", shortcut.Name),
            new XAttribute("WorkingDirectory", installDirectoryId),
            new XAttribute("Directory", directories[shortcut.Directory].Id),
            new XAttribute("Advertise", "yes"));

              // Не обязательные атрибуты.
              if (!string.IsNullOrWhiteSpace(shortcut.Arguments))
            xmlShortcut.Add(new XAttribute("Arguments", shortcut.Arguments));
              if (!string.IsNullOrWhiteSpace(shortcut.Description))
            xmlShortcut.Add(new XAttribute("Description", shortcut.Description));

              // Для иконки смотрим, если строка пустая и целевой файл содержит иконку,
              // то указываем сам файл.
              // Если строка не пустая, то указываем содержащийся в ней файл.
              if (string.IsNullOrWhiteSpace(shortcut.Icon))
              {
            if (IconHelper.ExtractIcon(pathToFile, 0, false) != null)
            {
              xmlShortcut.Add(new XAttribute("Icon", file.FileName));
              icons[file.FileName] = pathToFile;
            }
              }
              else
              {
            xmlShortcut.Add(new XAttribute("Icon", shortcut.Icon));
            icons[shortcut.Icon] = Path.Combine(context.SourceStoreDirectory, shortcut.Icon);
              }

              xmlFile.Add(xmlShortcut);
            }

            XElement xmlFragment = new XElement(XmlNameSpaceWIX + "Fragment");
            xmlWix.Add(xmlFragment);
            xmlFragment.Add(xmlDirectory);
            // Теперь сформируем теги для иконок.
            foreach (var icon in icons)
            {
              xmlFragment.Add(new XElement(XmlNameSpaceWIX + "Icon",
            new XAttribute("Id", icon.Key),
            new XAttribute("SourceFile", icon.Value)));
            }
              }
        }
Exemplo n.º 14
0
        public void SimpleFileName()
        {
            string fileName = "myapp.exe";

            Assert.AreEqual("MyappExe", WixComponentElement.GenerateIdFromFileName(fileName));
        }
 public void Init()
 {
     component = new WixComponentElement(new WixDocument());
 }
Exemplo n.º 16
0
        public void OnlyExtension()
        {
            string fileName = ".bat";

            Assert.AreEqual("Bat", WixComponentElement.GenerateIdFromFileName(fileName));
        }
Exemplo n.º 17
0
        public void NoExtension()
        {
            string fileName = "myapp";

            Assert.AreEqual("Myapp", WixComponentElement.GenerateIdFromFileName(fileName));
        }
Exemplo n.º 18
0
        public void SingleCharacterFileName()
        {
            string fileName = "a.bat";

            Assert.AreEqual("ABat", WixComponentElement.GenerateIdFromFileName(fileName));
        }
Exemplo n.º 19
0
 public void EmptyString()
 {
     Assert.AreEqual(String.Empty, WixComponentElement.GenerateIdFromFileName(String.Empty));
 }
Exemplo n.º 20
0
        public void Hyphen()
        {
            string fileName = "a-b.txt";

            Assert.AreEqual("A_bTxt", WixComponentElement.GenerateIdFromFileName(fileName));
        }
Exemplo n.º 21
0
        public void DotsInFileName()
        {
            string fileName = "a.b.txt";

            Assert.AreEqual("AbTxt", WixComponentElement.GenerateIdFromFileName(fileName));
        }
Exemplo n.º 22
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;
        }