Пример #1
0
        public override object[] Build()
        {
            List <object> items = new List <object>();

            // create custom acton
            Wix.CustomAction action = new Wix.CustomAction();
            action.Id = Common.GetId();
            if (String.IsNullOrEmpty(SourcePath))
            {
                Wix.Property property = new Wix.Property();
                property.Id   = Common.GetId();
                property.Text = new string[] { "<![CDATA[" + Script + "]]>" };
                items.Add(property);
                action.Property = property.Id;
            }
            else
            {
                if (IsInstalledFile == "True")
                {
                    if (Tag != null)
                    {
                        action.FileKey = ((ComponentNode)Tag).Property.Id;
                    }
                }
                else
                {
                    Wix.Binary binary = new Wix.Binary();
                    binary.Id         = Common.GetId();
                    binary.SourceFile = SourcePath;
                    action.BinaryKey  = binary.Id;
                    items.Add(binary);
                }
            }
            action.JScriptCall = Function;
            items.Add(action);
            // create install execute sequence
            Wix.InstallExecuteSequence executeSequence = new Wix.InstallExecuteSequence();
            executeSequence.ItemsElementName = new Wix.ItemsChoiceType2[] { Wix.ItemsChoiceType2.Custom };
            Wix.Custom custom = new Wix.Custom();
            custom.Action = action.Id;
            base.SetExecutionSequence(custom);
            base.SetExecuteType(custom);
            executeSequence.Items = new object[] { custom };
            items.Add(executeSequence);

            return(items.ToArray());
        }
Пример #2
0
        void INvnControl.Build()
        {
            //Copy license text
            File.Copy(LicenseFile.Text, Common.localWixFolder + Path.DirectorySeparatorChar + "License.rtf", true);
            // Copy images to wix folder
            ResourceManager res = new ResourceManager(typeof(Resources));

            if (Globals.registered)
            {
                if (txtBanner.Text != "[Default]")
                {
                    File.Copy(txtBanner.Text, Globals.localFolder + @"Wix\Bitmaps\bannrbmp.bmp", true);
                }
                else
                {
                    Bitmap bannerImg = (Bitmap)res.GetObject("bannrbmp");
                    bannerImg.Save(Common.localWixFolder + Path.DirectorySeparatorChar + "Bitmaps" + Path.DirectorySeparatorChar + "bannrbmp.bmp");
                }
                if (txtDialog.Text != "[Default]")
                {
                    File.Copy(txtDialog.Text, Globals.localFolder + @"Wix\Bitmaps\dlgbmp.bmp", true);
                }
                else
                {
                    Bitmap dlgImg = (Bitmap)res.GetObject("dlgbmp");
                    dlgImg.Save(Common.localWixFolder + Path.DirectorySeparatorChar + "Bitmaps" + Path.DirectorySeparatorChar + "dlgbmp.bmp");
                }
            }
            else
            {
                Bitmap bannerImg = (Bitmap)res.GetObject("bannrbmp");
                bannerImg.Save(Common.localWixFolder + Path.DirectorySeparatorChar + "Bitmaps" + Path.DirectorySeparatorChar + "bannrbmp.bmp");
                Bitmap dlgImg = (Bitmap)res.GetObject("dlgbmp");
                dlgImg.Save(Common.localWixFolder + Path.DirectorySeparatorChar + "Bitmaps" + Path.DirectorySeparatorChar + "dlgbmp.bmp");
            }

            //<Product>
            string[] selectedLanguage = ((string)cmbLanguage.SelectedValue).Split("|".ToCharArray());
            MsiBuilder.Product              = new Wix.Product();
            MsiBuilder.Product.Name         = ProductName.Text;
            MsiBuilder.Product.Version      = Version.Text;
            MsiBuilder.Product.Id           = ProductCode.Text;
            MsiBuilder.Product.UpgradeCode  = UpgradeCode.Text;
            MsiBuilder.Product.Language     = selectedLanguage[0];
            MsiBuilder.Product.Codepage     = selectedLanguage[1];
            MsiBuilder.UILocalizedFile      = selectedLanguage[2];
            MsiBuilder.Product.Manufacturer = Manufacturer.Text;
            //<Product>/<Package>
            MsiBuilder.Product.Package          = new Wix.Package();
            MsiBuilder.Product.Package.Id       = PackageId.Text;
            MsiBuilder.Product.Package.Keywords = "Installer";
            if (Description.Text != string.Empty)
            {
                MsiBuilder.Product.Package.Description = Description.Text;
            }
            if (Comments.Text != string.Empty)
            {
                MsiBuilder.Product.Package.Comments = Comments.Text;
            }
            MsiBuilder.Product.Package.Manufacturer = Manufacturer.Text;
            int majorInstallerVersion = Int32.Parse(txtMajorVersion.Text);
            int minorInstallerVersion = String.IsNullOrEmpty(txtMinorVersion.Text) ? 0 : Int32.Parse(txtMinorVersion.Text);

            MsiBuilder.Product.Package.InstallerVersion    = (majorInstallerVersion * 100 + minorInstallerVersion).ToString();
            MsiBuilder.Product.Package.Languages           = selectedLanguage[0];
            MsiBuilder.Product.Package.CompressedSpecified = true;
            MsiBuilder.Product.Package.Compressed          = Wix.YesNoType.yes;
            MsiBuilder.Product.Package.SummaryCodepage     = selectedLanguage[1];
            if (chk64Bit.Checked)
            {
                MsiBuilder.Product.Package.Platforms = "x64";
            }

            //Build User Interface
            Wix.UIRef uiRef1 = new Wix.UIRef();
            if (rbMondo.Checked)
            {
                uiRef1.Id = "WixUI_Mondo";
            }
            else if (rbFeatureTree.Checked)
            {
                uiRef1.Id = "WixUI_FeatureTree";
            }
            else if (rbInstall.Checked)
            {
                uiRef1.Id = "WixUI_InstallDir";
                Wix.Property installDirProperty = new Wix.Property();
                installDirProperty.Id    = "WIXUI_INSTALLDIR";
                installDirProperty.Value = "INSTALLDIR";
                MsiBuilder.PropertyElements.Add(installDirProperty.Id, installDirProperty);
            }
            else if (rbMinimal.Checked)
            {
                uiRef1.Id = "WixUI_Minimal";
            }
            Wix.UIRef uiRef2 = new Wix.UIRef();
            uiRef2.Id = "WixUI_ErrorProgressText";
            MsiBuilder.UIRef.Add(uiRef1);
            MsiBuilder.UIRef.Add(uiRef2);

            // application is installed for all users ...
            Wix.Property allUsersProp = new Wix.Property();
            allUsersProp.Id    = "ALLUSERS";
            allUsersProp.Value = "1";
            MsiBuilder.PropertyElements.Add(allUsersProp.Id, allUsersProp);

            // Set properties for Icon
            if (String.IsNullOrEmpty(IconFile.Text) == false)
            {
                Wix.Icon icon = new Wix.Icon();
                icon.Id         = "iconfile.exe"; // STRANGE : The Id for the Icon element must end in '.exe' (i.e. LinkedCells.exe)
                icon.SourceFile = IconFile.Text;
                MsiBuilder.ProductMiscElements.Add(icon);

                Wix.Property productIconProp = new Wix.Property();
                productIconProp.Id    = "ARPPRODUCTICON";
                productIconProp.Value = icon.Id;
                MsiBuilder.PropertyElements.Add(productIconProp.Id, productIconProp);
            }

            #region Features
            if (tvFeatures.Nodes.Count > 0)
            {
                TreeNode        rootFeatureNode = tvFeatures.Nodes[0];
                FeatureProperty property        = (FeatureProperty)rootFeatureNode.Tag;
                if (property != null)
                {
                    MsiBuilder.Feature.Id                    = property.Id;
                    MsiBuilder.Feature.Title                 = property.Name;
                    MsiBuilder.Feature.Description           = property.Description;
                    MsiBuilder.Feature.Display               = "expand";
                    MsiBuilder.Feature.Level                 = "1";
                    MsiBuilder.Feature.ConfigurableDirectory = "INSTALLDIR";
                    MsiBuilder.FeatureTable.Add(MsiBuilder.Feature.Id, MsiBuilder.Feature);

                    foreach (TreeNode featureNode in rootFeatureNode.Nodes)
                    {
                        CreateFeature(featureNode, MsiBuilder.Feature);
                    }
                }
            }
            #endregion

            // Prerequisites
            if (cmbPrerequisite.SelectedIndex != 0) /* If selected item is not NONE */
            {
                MsiCompiler.BootstrapperName = (string)cmbPrerequisite.SelectedValue;
            }
        }
Пример #3
0
        void INvnControl.Build()
        {
            if (Common.Features.Nodes.Count > 0)
            {
                Wix.Directory targetDir = new Wix.Directory();
                MsiBuilder.TargetDirectory = targetDir;
                targetDir.Id    = "TARGETDIR";
                targetDir.Name  = "SourceDir";
                targetDir.Items = new Wix.Directory[3 + Enum.GetNames(typeof(SystemFolderType)).Length];// Program files, desktop shortcuts, start menu and all special folders

                // COMPONENTS DIRECTORY
                if (tvComponents.Nodes.Count > 0 && tvComponents.Nodes[0].Text != "")
                {
                    Wix.Directory pFilesDir = new Wix.Directory();
                    pFilesDir.Id       = "ProgramFilesFolder";
                    pFilesDir.Name     = "PFiles";
                    targetDir.Items[0] = pFilesDir;

                    pFilesDir.Items = new Wix.Directory[1];
                    TreeNode      INSTALLDIR_Node = null;
                    Wix.Directory INSTALLDIR      = null;
                    string        directoryPath   = @"$(env.ProgramFiles)\";
                    switch (componentsRootFolderType)
                    {
                    case ComponentsRootFolderType.Program_product:
                        directoryPath  += ControlsManager.ProductInformation.ProductName.Text;
                        INSTALLDIR_Node = tvComponents.Nodes[0].Nodes[0];
                        break;

                    case ComponentsRootFolderType.Program_Manufacturer_Product:
                        directoryPath += ControlsManager.ProductInformation.Manufacturer.Text
                                         + "\\" + ControlsManager.ProductInformation.ProductName.Text;
                        INSTALLDIR_Node = tvComponents.Nodes[0].Nodes[0].Nodes[0];
                        break;

                    case ComponentsRootFolderType.Program_Custom:
                        directoryPath  += tvComponents.Nodes[0].Nodes[0].Text;
                        INSTALLDIR_Node = tvComponents.Nodes[0].Nodes[0];
                        break;

                    case ComponentsRootFolderType.Custom:
                        directoryPath   = tvComponents.Nodes[0].Text;
                        INSTALLDIR_Node = tvComponents.Nodes[0];
                        break;
                    }

                    Wix.Property propertyElement = new Wix.Property();
                    propertyElement.Id   = "INSTALLDIR";
                    propertyElement.Text = new string[] { string.Format(@"<![CDATA[{0}]]>", directoryPath) };
                    MsiBuilder.PropertyElements.Add(propertyElement.Id, propertyElement);

                    Wix.Directory customDir = new Wix.Directory();
                    customDir.Id       = "INSTALLDIR";
                    customDir.Name     = ".";
                    pFilesDir.Items[0] = customDir;
                    INSTALLDIR         = customDir;

                    MsiBuilder.InstallDirectory = INSTALLDIR;

                    // SYSTEM FOLDERS
                    BuildSystemFolders(targetDir);

                    // SHORTCUT FOLDERS
                    BuildShortcutFolders(targetDir);

                    // COMPONENTS DIRECTORY
                    BuildWixDirectory(INSTALLDIR, INSTALLDIR_Node, false);
                }
            }
        }
Пример #4
0
        void INvnControl.Build()
        {
            foreach (WindowsProperty property in propertyItems.Items)
            {
                Wix.Property msiProperty = new Wix.Property();
                msiProperty.Id    = property.Name;
                msiProperty.Value = property.DefaultValue;

                // PROPERTY SEARCH
                switch (property.SearchType)
                {
                case PropertySearchType.DirectorySearch:
                    Wix.DirectorySearch wixDirSearch = new Wix.DirectorySearch();
                    wixDirSearch.Id = Common.GetId();
                    DirectorySearch dirSearch = (DirectorySearch)property.propSearch[PropertySearchType.DirectorySearch];
                    wixDirSearch.Path           = dirSearch.DirectoryPath;
                    wixDirSearch.Depth          = dirSearch.Depth;
                    msiProperty.DirectorySearch = new Wix.DirectorySearch[] { wixDirSearch };
                    break;

                case PropertySearchType.FileSearch:
                    Wix.DirectorySearch wixFlDirSearch = new Wix.DirectorySearch();
                    wixFlDirSearch.Id = Common.GetId();
                    FileSearch flDirSearch = (FileSearch)property.propSearch[PropertySearchType.FileSearch];
                    wixFlDirSearch.Path  = flDirSearch.DirectoryPath;
                    wixFlDirSearch.Depth = flDirSearch.Depth;
                    Wix.FileSearch wixFileSearch = new Wix.FileSearch();
                    wixFileSearch.Id            = Common.GetId();
                    wixFileSearch.Name          = flDirSearch.FileName;
                    wixFlDirSearch.Item         = wixFileSearch;
                    msiProperty.DirectorySearch = new Wix.DirectorySearch[] { wixFlDirSearch };
                    break;

                case PropertySearchType.INISearch:
                    Wix.IniFileSearch wixIniSearch = new Wix.IniFileSearch();
                    wixIniSearch.Id = Common.GetId();
                    INISearch iniSearch = (INISearch)property.propSearch[PropertySearchType.INISearch];
                    wixIniSearch.Name         = iniSearch.Name;
                    wixIniSearch.Section      = iniSearch.Section;
                    wixIniSearch.Key          = iniSearch.Key;
                    msiProperty.IniFileSearch = new Wix.IniFileSearch[] { wixIniSearch };
                    break;

                case PropertySearchType.None: break;

                case PropertySearchType.RegistrySearch:
                    Wix.RegistrySearch wixRegSearch = new Wix.RegistrySearch();
                    wixRegSearch.Id = Common.GetId();
                    RegistrySearch regSearch = (RegistrySearch)property.propSearch[PropertySearchType.RegistrySearch];
                    wixRegSearch.Root          = (Wix.RegistrySearchRoot)Enum.Parse(typeof(Wix.RegistrySearchRoot), regSearch.Root);
                    wixRegSearch.Key           = regSearch.Key;
                    wixRegSearch.Name          = regSearch.Name;
                    msiProperty.RegistrySearch = new Wix.RegistrySearch[] { wixRegSearch };
                    break;
                }

                if (MsiBuilder.PropertyElements.ContainsKey(msiProperty.Id))
                {
                    MsiBuilder.PropertyElements[msiProperty.Id] = msiProperty;
                }
                else
                {
                    MsiBuilder.PropertyElements.Add(msiProperty.Id, msiProperty);
                }
            }
        }