Defines directory to be installed on target system.

Use this class to define file/directory structure of the deployment solution.

You can use predefined Wix# environment constants for well-known installation locations. They are directly mapped to the corresponding WiX constants:

Wix# - WiX

%WindowsFolder% - [WindowsFolder]

%ProgramFiles% - [ProgramFilesFolder]

%ProgramMenu% - [ProgramMenuFolder]

%AppDataFolder% - [AppDataFolder]

%CommonFilesFolder% - [CommonFilesFolder]

%LocalAppDataFolder% - [LocalAppDataFolder]

%ProgramFiles64Folder% - [ProgramFiles64Folder]

%System64Folder% - [System64Folder]

%SystemFolder% - [SystemFolder]

%TempFolder% - [TempFolder]

%Desktop% - [DesktopFolder]

Inheritance: WixEntity
        public static string Execute()
        {
            Feature obsPlugin = new Feature("Obs Plugin");
            var obsDir = new Dir(@"%ProgramFiles%\OBS\plugins",
                new File(obsPlugin, @"ObsPlugin\CLRHostPlugin.dll"),
                new Dir(obsPlugin, "CLRHostPlugin",
                    new DirFiles(obsPlugin, @"ObsPlugin\CLRHostPlugin\*.*")
                    ));

            Project project = new Project("OBS plugin for digiCamControl",obsDir);

            project.SetNetFxPrerequisite("NETFRAMEWORK45 >= '#378389'", "Please install .Net 4.5 First");
            project.UI = WUI.WixUI_Minimal;
            project.GUID = new Guid("357E0D80-5093-478E-8C11-28B1A72096E7");

            #if DEBUG
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Debug\"));
            #else
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Release\"));
            #endif

            FileVersionInfo ver = null;
            try
            {
                ver =
                    FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, @"ObsPlugin\CLRHostPlugin", "DccObsPlugin.dll"));
            }
            catch (FileNotFoundException ex)
            {
                project.SourceBaseDir = project.SourceBaseDir.Replace(@"Setup\bin\", "");
                ver =
                    FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, @"ObsPlugin\CLRHostPlugin", "DccObsPlugin.dll"));
            }

            project.LicenceFile = @"Licenses\DigiCamControlLicence.rtf";

            project.Version = new Version(ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            //project.MajorUpgradeStrategy.NewerProductInstalledErrorMessage = "A version of the digiCamControl already installed. Unistall it first from Control Panel !";
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;
            ////project.MajorUpgradeStrategy.UpgradeVersions = VersionRange.ThisAndOlder;
            ////project.MajorUpgradeStrategy.PreventDowngradingVersions = VersionRange.ThisAndOlder;

            project.ControlPanelInfo.Manufacturer = "Duka Istvan";
            project.OutFileName = string.Format("ObsPluginSetup_{0}", ver.FileVersion);
            project.ControlPanelInfo.ProductIcon = "logo.ico";
            project.InstallScope = InstallScope.perMachine;

            project.ResolveWildCards();
            Compiler.PreserveTempFiles = false;
            return Compiler.BuildMsi(project);
        }
Exemple #2
0
 static public void Main(string[] args)
 {
     Dir directory = new Dir("AppDirectory");
     directory.Files.Add(new File("readme.txt"));
     /*directory.Files.Add(new File(@"..\wixsh\bin\debug\wixsh.exe"));
     directory.Files.Add(new File(@"..\wixsh\bin\debug\wixsh.exe.config"));*/
     var project = new Project("Wix# Test");
     project.Dirs.Add(directory);
     /*project.Actions.Add(new InstalledFileAction("wixsh.exe", 
         String.Empty, 
         Return.check, 
         When.After,
         Step.InstallFinalize, 
         Condition.Installed));*/
     project.Actions.Add(new ManagedAction("MyAction"));
     project.UI = WUI.WixUI_ProgressOnly;
     Compiler.BuildMsi(project);
 }
Exemple #3
0
    public static void Main(string[] args)
    {
        //var project = new Project("MyProduct",
        //    new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"Files\Bin\MyApp.exe"),
        //    new Dir(@"docs\manual", new File(@"Files\Docs\Manual.txt"))));

        //project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        //Compiler.BuildMsi(project);

        //

           // var binDir = new WixSharp.Dir(@"bin");

        var binFile = new File(@"Files\Bin\MyApp.exe");
        var docFile = new File(@"Files\Docs\Manual.txt");

          var binFiles = new WixSharp.File[]
          {
             binFile
          };

          var docFiles = new WixSharp.File[]
          {
              docFile
          };

        var binDir = new WixSharp.Dir(@"bin", binFiles);
        var docDir = new WixSharp.Dir(@"doc", docFiles);

        var mainDir = new WixSharp.Dir(@"%ProgramFiles%\My Company\DigDes WixSharp",
             binDir,
             docDir );

        //
        Project project = new Project("DigDes WixSharp",  mainDir );

        project.UI = WUI.WixUI_Common;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");

        Compiler.BuildMsi(project);
    }
Exemple #4
0
        Dir ProcessTargetPath(string targetPath)
        {
            Dir currDir = this;

            if (System.IO.Path.IsPathRooted(targetPath))
            {
                this.Name = targetPath;
            }
            else
            {
                //create nested Dirs on-fly
                var nestedDirs = targetPath.Split("\\/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                this.Name = nestedDirs.First();
                for (int i = 1; i < nestedDirs.Length; i++)
                {
                    Dir nextSubDir = new Dir(nestedDirs[i]);
                    nextSubDir.AutoParent = currDir;
                    //currDir.MoveAttributesTo(nextSubDir); //attributes may not be set at this stage
                    currDir.Dirs = new Dir[] { nextSubDir };
                    currDir = nextSubDir;
                }
            }

            return currDir;
        }
Exemple #5
0
        internal Dir(Feature feature, string targetPath, Project project)
        {
            //create nested Dirs on-fly but reuse already existing ones in the project
            var nestedDirs = targetPath.Split("\\/".ToCharArray());

            Dir lastFound = null;
            string lastMatching = null;
            string[] flatTree = ToFlatPathTree(targetPath);

            foreach (string path in flatTree)
            {
                var existingDir = project.FindDir(path);
                if (existingDir != null)
                {
                    lastFound = existingDir;
                    lastMatching = path;
                }
                else
                {
                    if (lastFound != null)
                    {
                        Dir currDir = lastFound;

                        string[] newSubDirs = targetPath.Substring(lastMatching.Length + 1).Split("\\/".ToCharArray());
                        for (int i = 0; i < newSubDirs.Length; i++)
                        {
                            Dir nextSubDir = new Dir(newSubDirs[i]);
                            currDir.Dirs = new Dir[] { nextSubDir };
                            currDir = nextSubDir;
                        }

                        currDir.Feature = feature;
                    }
                    else
                    {
                        Dir lastDir = ProcessTargetPath(targetPath);
                        lastDir.Feature = feature;
                    }
                    break;
                }
            }
        }
Exemple #6
0
        static void ProcessOdbcSources(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement dirItem)
        {
            foreach (ODBCDataSource wODBCDataSource in wDir.ODBCDataSources)
            {
                string dsnId = wODBCDataSource.Id;
                string compId = "Component." + wODBCDataSource.Id;

                if (wODBCDataSource.Feature != null)
                {
                    if (!featureComponents.ContainsKey(wODBCDataSource.Feature))
                        featureComponents[wODBCDataSource.Feature] = new List<string>();

                    featureComponents[wODBCDataSource.Feature].Add(compId);
                }
                else
                {
                    defaultFeatureComponents.Add(compId);
                }

                XElement comp = dirItem.AddElement(
                   new XElement("Component",
                       new XAttribute("Id", compId),
                       new XAttribute("Guid", WixGuid.NewGuid(compId))));

                XElement dsn = comp.AddElement(
                    new XElement("ODBCDataSource",
                        new XAttribute("Id", wODBCDataSource.Id),
                        new XAttribute("Name", wODBCDataSource.Name),
                        new XAttribute("DriverName", wODBCDataSource.DriverName),
                        new XAttribute("KeyPath", wODBCDataSource.KeyPath.ToYesNo()),
                        new XAttribute("Registration", (wODBCDataSource.PerMachineRegistration ? "machine" : "user"))));

                foreach (Property prop in wODBCDataSource.Properties)
                {
                    dsn.AddElement(
                        new XElement("Property",
                                    new XAttribute("Id", prop.Name),
                                    new XAttribute("Value", prop.Value)));
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dir"/> class with properties/fields initialized with specified parameters
 /// </summary>
 /// <param name="id">The explicit <see cref="Id"></see> to be associated with <see cref="Dir"/> instance.</param>
 /// <param name="targetPath">The name of the directory. Note if the directory is a root installation directory <c>targetPath</c> must
 /// be specified as a full path. However if the directory is a nested installation directory the name must be a directory name only.</param>
 /// <param name="items">Any <see cref="WixEntity"/> which can be contained by directory (e.g. file, subdirectory).</param>
 public Dir(Id id, string targetPath, params WixEntity[] items)
 {
     lastDir = ProcessTargetPath(targetPath);
     lastDir.AddItems(items);
     lastDir.Id = id;
 }
Exemple #8
0
        static void Main(string[] args)
        {
            Feature appFeature = new Feature("Application files", "Main application files", true, false, @"INSTALLDIR");
            var shortcut = new FileShortcut(appFeature, "ShootingLab", @"%ProgramMenu%\digiCamControl") { WorkingDirectory = @"INSTALLDIR" };
            var shortcutD = new FileShortcut(appFeature, "ShootingLab", @"%Desktop%") { WorkingDirectory = @"INSTALLDIR" };
            var appDir = new Dir(@"ShootingLab",
                new WixSharp.File(appFeature, "ShootingLab.exe", shortcut, shortcutD),
                new DirFiles(appFeature, @"*.dll")
                //new WixSharp.File(appFeature, "shootingLab.ico")
                );

            var baseDir = new Dir(@"%ProgramFiles%\",
                appDir);

            Project project = new Project("ShootingLab",
                    new LaunchCondition("NET40=\"#1\"", "Please install .NET 4.0 first."),
                    baseDir,
                    new RegValueProperty("NET40", RegistryHive.LocalMachine,
                        @"Software\Microsoft\NET Framework Setup\NDP\v4\Full", "Install", "0"),
                    new ManagedAction(@"MyAction", Return.ignore, When.Before, Step.InstallExecute,
                        Condition.NOT_Installed, Sequence.InstallExecuteSequence),
                    new ManagedAction(@"SetRightAction", Return.ignore, When.Before, Step.InstallFinalize,
                        Condition.Always, Sequence.InstallExecuteSequence)
                    );

            project.UI = WUI.WixUI_FeatureTree;
            project.GUID = new Guid("4E22C775-897C-41D5-8009-1A4A616149B2");

            project.SourceBaseDir =
                Path.GetFullPath(@"C:\Développements\LaboPDV\ShootingLab\bin\Release\");

            FileVersionInfo ver =
                FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "ShootingLab.exe"));

            //project.LicenceFile = @"Licenses\ShootingLabLicence.rtf";

            project.Version = new Version(ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;

            project.ControlPanelInfo.Manufacturer = "PixVert";
            project.OutFileName = string.Format("ShootingLabSetup_{0}", ver.FileVersion);
            //project.ControlPanelInfo.ProductIcon = "shootingLab.ico";

            project.ResolveWildCards();

            Compiler.PreserveTempFiles = true;
            Compiler.BuildMsi(project);
        }
Exemple #9
0
        static XElement AddDir(XElement parent, Dir wDir)
        {
            string name = wDir.Name;
            string id = "";

            if (wDir.IsIdSet())
            {
                id = wDir.Id;
            }
            else
            {
                //Special folder defined either directly or by Wix# environment constant
                //e.g. %ProgramFiles%, [ProgramFilesFolder] -> ProgramFilesFolder
                if (Compiler.EnvironmentConstantsMapping.ContainsKey(wDir.Name) ||                              // %ProgramFiles%
                    Compiler.EnvironmentConstantsMapping.ContainsValue(wDir.Name) ||                            // ProgramFilesFolder
                    Compiler.EnvironmentConstantsMapping.ContainsValue(wDir.Name.TrimStart('[').TrimEnd(']')))  // [ProgramFilesFolder]
                {
                    id = wDir.Name.Expand();
                    name = wDir.Name.Expand(); //name needs to be escaped
                }
                else
                {
                    id = parent.Attribute("Id").Value + "." + wDir.Name.Expand();
                }
            }

            XElement newSubDir = parent.AddElement(
                                             new XElement("Directory",
                                                 new XAttribute("Id", id),
                                                 new XAttribute("Name", name)));

            return newSubDir;
        }
Exemple #10
0
        static void ProcessMergeModules(Dir wDir, XElement dirItem, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents)
        {
            foreach (Merge msm in wDir.MergeModules)
            {
                XElement media = dirItem.Parent("Product").Select("Media");
                XElement package = dirItem.Parent("Product").Select("Package");

                string language = package.Attribute("Languages").Value; //note Wix# expects package.Attribute("Languages") to have a single value (yest it is a temporary limitation)
                string diskId = media.Attribute("Id").Value;

                XElement merge = dirItem.AddElement(
                    new XElement("Merge",
                        new XAttribute("Id", msm.Id),
                        new XAttribute("FileCompression", msm.FileCompression.ToYesNo()),
                        new XAttribute("Language", language),
                        new XAttribute("SourceFile", msm.SourceFile),
                        new XAttribute("DiskId", diskId))
                        .AddAttributes(msm.Attributes));

                if (!featureComponents.ContainsKey(msm.Feature))
                    featureComponents[msm.Feature] = new List<string>();

                //currently WiX does not allow child Condition element but in the future release it most likely will
                //if (msm.Condition != null)
                //    merge.AddElement(
                //        new XElement("Condition", new XCData(msm.Condition.ToCData()))
                //            .AddAttributes(msm.Condition.Attributes));
            }
        }
Exemple #11
0
        /// <summary>
        /// Analyses <paramref name="baseDirectory"/> and returns all files (including subdirectories) matching <see cref="Files.IncludeMask"/>,
        /// which are not matching any <see cref="Files.ExcludeMasks"/>.
        /// </summary>
        /// <param name="baseDirectory">The base directory for file analysis. It is used in conjunction with
        /// relative <see cref="Files.Directory"/>. Though <see cref="Files.Directory"/> takes precedence if it is an absolute path.</param>
        /// <returns>Array of <see cref="WixEntity"/> instances, which are either <see cref="File"/> or/and <see cref="Dir"/> objects.</returns>
        public WixEntity[] GetAllItems(string baseDirectory)
        {
            if (IO.Path.IsPathRooted(Directory))
                baseDirectory = Directory;
            if (baseDirectory.IsEmpty())
                baseDirectory = Environment.CurrentDirectory;

            baseDirectory = IO.Path.GetFullPath(baseDirectory);

            string rootDirPath;
            if (IO.Path.IsPathRooted(Directory))
                rootDirPath = Directory;
            else
                rootDirPath = Utils.PathCombine(baseDirectory, Directory);

            Action<Dir, string> AgregateSubDirs = null;
            AgregateSubDirs = delegate(Dir parentDir, string dirPath)
                                {
                                    foreach (var subDirPath in IO.Directory.GetDirectories(dirPath))
                                    {
                                        var dirName = IO.Path.GetFileName(subDirPath);
                                        var subDir = new Dir(this.Feature, dirName, new DirFiles(IO.Path.Combine(subDirPath, this.IncludeMask))
                                                                      {
                                                                          Feature = this.Feature,
                                                                          //ExcludeMasks = this.ExcludeMasks,
                                                                          Filter = this.Filter
                                                                      });
                                        AgregateSubDirs(subDir, subDirPath);

                                        parentDir.Dirs = parentDir.Dirs.Add(subDir);
                                    }
                                };

            var items = new List<WixEntity>
            {
                new DirFiles(IO.Path.Combine(rootDirPath, this.IncludeMask))
                {
                    Feature=this.Feature,
                    //ExcludeMasks = this.ExcludeMasks,
                    Filter = this.Filter
                }
            };

            if (!IO.Directory.Exists(rootDirPath))
                throw new IO.DirectoryNotFoundException(rootDirPath);

            foreach (var subDirPath in System.IO.Directory.GetDirectories(rootDirPath))
            {
                var dirName = IO.Path.GetFileName(subDirPath);
                var subDir = new Dir(this.Feature, dirName, new DirFiles(IO.Path.Combine(subDirPath, this.IncludeMask))
                                              {
                                                  Feature = this.Feature,
                                                  //ExcludeMasks = this.ExcludeMasks,
                                                  Filter = this.Filter
                                              });
                AgregateSubDirs(subDir, subDirPath);

                items.Add(subDir);
            }

            return items.ToArray();
        }
Exemple #12
0
        public static void Main(string[] args)
        {
            Feature appFeature = new Feature("Application files", "Main application files", true, false, @"INSTALLDIR");
            Feature obsPlugin = new Feature("Obs Plugin");

            var appDir = new Dir(@"digiCamControl",
                new File(appFeature, "CameraControl.exe",
                    new FileShortcut(appFeature,"digiCamControl", @"%ProgramMenu%\digiCamControl"),
                    new FileShortcut(appFeature, "digiCamControl", @"%Desktop%")),
                new File(appFeature, "CameraControl.PluginManager.exe"),
                new File(appFeature, "CameraControlCmd.exe"),
                new File(appFeature, "CameraControlRemoteCmd.exe"),
                new File(appFeature, "dcraw.exe"),
                new File(appFeature, "ffmpeg.exe"),
                new File(appFeature, "ngrok.exe"),
                new File(appFeature, "MtpTester.exe"),
                //new File(appFeature, "PhotoBooth.exe",new FileShortcut(appFeature, "PhotoBooth", @"%ProgramMenu%\digiCamControl")),
                new DirFiles(appFeature, @"*.dll"),
            #if DEBUG
                new DirFiles(appFeature, @"*.pdb"),
            #endif
                new File(appFeature, "regwia.bat"),
                new File(appFeature, "logo.ico"),
                new File(appFeature, "logo_big.jpg"),
                new File(appFeature, "baseMtpDevice.xml"),
                new DirFiles(appFeature, @"*.png"),
                new File(appFeature, "DigiCamControl.xbs"),
                new Dir(appFeature, "Data",
                    new Files(appFeature, @"Data\*.*")),
                //new Dir(appFeature, "Plugins",
                //    new Files(appFeature, @"Plugins\*.*", "MahApps.Metro.*", "System.Windows.Interactivity.*",
                //        "WriteableBitmapEx.Wpf.*", "GalaSoft.MvvmLight.*", "*.config")),
                new Dir(appFeature, "Plugins",
                    new Dir(appFeature, "CameraControl.Plugins",
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\CameraControl.Plugins.dll"),
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\dcc.plugin")),
                    new Dir(appFeature, "Plugin.DeviceControlBox",
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\Plugin.DeviceControlBox.dll"),
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\dcc.plugin"))
                    ),
                new Dir(appFeature, "Languages",
                    new DirFiles(appFeature, @"Languages\*.xml")),
                new Dir(appFeature, "Licenses",
                    new DirFiles(appFeature, @"Licenses\*.*")),
                new Dir(appFeature, "Tools",
                    new DirFiles(appFeature, @"Tools\*.*")),
                new Dir(appFeature, "WebServer",
                    new Files(appFeature, @"WebServer\*.*"))
                );

            var obsDir = new Dir(@"OBS\plugins",
                new File(obsPlugin, @"ObsPlugin\CLRHostPlugin.dll"),
                new Dir(obsPlugin, "CLRHostPlugin",
                    new DirFiles(obsPlugin, @"ObsPlugin\CLRHostPlugin\*.*")
                    ));

            var baseDir = new Dir(@"%ProgramFiles%\",
                appDir ,
                obsDir
                );

            Project project = new Project("digiCamControl",
                new LaunchCondition("NET40=\"#1\"", "Please install .NET 4.0 first."),
                baseDir,
                new RegValueProperty("NET40", RegistryHive.LocalMachine,
                    @"Software\Microsoft\NET Framework Setup\NDP\v4\Full", "Install", "0"),
                new ManagedAction(@"MyAction", Return.ignore, When.Before, Step.LaunchConditions,
                    Condition.NOT_Installed, Sequence.InstallUISequence),
                new ManagedAction(@"SetRightAction", Return.ignore, When.Before, Step.InstallFinalize,
                    Condition.Always, Sequence.InstallExecuteSequence)
                );

            project.UI = WUI.WixUI_FeatureTree;
            project.GUID = new Guid("19d12628-7654-4354-a305-9ab0932af676");

            #if DEBUG
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Debug\"));
            #else
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Release\"));
            #endif
            project.ResolveWildCards();

            FileVersionInfo ver =
                FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "CameraControl.exe"));

            project.LicenceFile = @"Licenses\DigiCamControlLicence.rtf";

            project.Version = new Version(ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;

            project.ControlPanelInfo.Manufacturer = "Duka Istvan";
            project.OutFileName = string.Format("digiCamControlsetup_{0}", ver.FileVersion);
            project.ControlPanelInfo.ProductIcon = "logo.ico";

            string branding = Path.Combine(project.SourceBaseDir, "branding.xml");
            if (System.IO.File.Exists(branding))
            {
                var doc = new XmlDocument();
                doc.LoadXml(System.IO.File.ReadAllText(branding));
                string name = doc.DocumentElement.SelectSingleNode("/Branding/ApplicationTitle").InnerText;
                project.ControlPanelInfo.Manufacturer = name;
                project.OutFileName = string.Format(name+"_{0}", ver.FileVersion);
                appDir.AddFile(new File(appFeature, "branding.xml"));
                project.Name = name;
            }

            Compiler.PreserveTempFiles = true;
            Compiler.BuildMsi(project);
        }
Exemple #13
0
        static void Main(string[] args)
        {
            try
            {
                WixSharp.File ui = new WixSharp.File(
                    @"cli\WindowsServiceTestClient.exe",
                    new WixSharp.FileShortcut("WindowsServiceTestClient", @"%ProgramMenu%\cocoalix")
                {
                    Advertise = true
                }
                    );
                WixSharp.File service = new WixSharp.File(
                    @"service\WindowsServiceTest.exe"
                    );
                WixSharp.Files uiDepends = new WixSharp.Files(
                    @"cli\*.*"
                    );
                WixSharp.Files serviceDepends = new WixSharp.Files(
                    @"service\*.*"
                    );

                var dir = new WixSharp.Dir(new WixSharp.Id("InstallDir"),
                                           @"%ProgramFiles%\cocoalix",
                                           // インストーラーにインクルードするファイル
                                           ui,
                                           // インストーラーにインクルードするファイル
                                           service,
                                           uiDepends,
                                           serviceDepends
                                           );

                var project = new WixSharp.ManagedProject("ウィンドウズサービステスト", dir);

                project.Platform = Platform.x64;

                // 日本語をインストーラ及びWiXで仕様するためのおまじない
                project.Codepage = "932";
                project.Language = "ja-JP";

                // アップグレードコードを指定 (変更厳禁)
                project.GUID = new Guid("abbb7cf9-19fa-45f2-babc-a35312741772");

                // インストーラーのファイル名
                project.OutFileName = "ウィンドウズサービステストインストーラ";

                service.ServiceInstaller = new WixSharp.ServiceInstaller
                {
                    Account      = @"NT Authority\System",
                    PermissionEx = new WixSharp.PermissionEx()
                    {
                        User = @"Administrator",
                        ServicePauseContinue = false,
                        ServiceStart         = true,
                        ServiceStop          = true,
                    },
                    Name                    = "WindowsServiceTestService",
                    Description             = "ウィンドウズサービステストのサービスです",
                    StartOn                 = WixSharp.SvcEvent.Install,
                    StopOn                  = WixSharp.SvcEvent.InstallUninstall_Wait,
                    RemoveOn                = WixSharp.SvcEvent.Uninstall_Wait,
                    DelayedAutoStart        = true,
                    FirstFailureActionType  = WixSharp.FailureActionType.restart,
                    SecondFailureActionType = WixSharp.FailureActionType.restart,
                    ThirdFailureActionType  = WixSharp.FailureActionType.none,
                    PreShutdownDelay        = 1000 * 60 * 3,
                    ServiceSid              = WixSharp.ServiceSid.none,
                };

                // インストーラで表示するウィンドウ群の指定
                project.ManagedUI = new WixSharp.ManagedUI();
                project.ManagedUI.InstallDialogs.Add(WixSharp.Forms.Dialogs.Welcome)
                .Add(WixSharp.Forms.Dialogs.Licence)
                .Add(WixSharp.Forms.Dialogs.Progress)
                .Add(WixSharp.Forms.Dialogs.Exit);

                project.LicenceFile = @"Eula.rtf";

                // インストール時権限昇格
                project.InstallPrivileges = InstallPrivileges.elevated;
                project.InstallScope      = InstallScope.perMachine;

                project.PreserveTempFiles = true;

                var projectMsi = project.BuildMsi();

                var bootstrapper = new Bundle(
                    "ウィンドウズサービステスト_バンドルインストーラ",
                    new ExePackage()
                {
                    Id               = "DotNet5DesktopRuntime",
                    Name             = "dotnet5-windowsdesktop-runtime-5.0-win-x64.exe",
                    Vital            = true,
                    Permanent        = false,
                    DownloadUrl      = @"https://download.visualstudio.microsoft.com/download/pr/7a5d15ae-0487-428d-8262-2824279ccc00/6a10ce9e632bce818ce6698d9e9faf39/windowsdesktop-runtime-5.0.4-win-x64.exe",
                    InstallCommand   = "/install /quiet",
                    RepairCommand    = "/repair /quiet",
                    UninstallCommand = "/uninstall /quiet",
                    LogPathVariable  = "dotnet5desktopruntime.log",
                    Compressed       = true,

                    // RemotePayloadは以下のコマンドで取得可能
                    // heat payload <バンドルしたいexeのバイナリのパス> -out .\remote.xml
                    RemotePayloads = new[]
                    {
                        new RemotePayload()
                        {
                            ProductName           = "Microsoft Windows Desktop Runtime - 5.0.4 (x64)",
                            Description           = "Microsoft Windows Desktop Runtime - 5.0.4 (x64)",
                            Hash                  = "33FBCDB6B6F052FCC26B4EF850B81ED5F2C10B02",
                            Size                  = 54790696,
                            Version               = "5.0.4.29817".ToRawVersion(),
                            CertificatePublicKey  = "3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18",
                            CertificateThumbprint = "2485A7AFA98E178CB8F30C9838346B514AEA4769"
                        }
                    }
                },
                    new MsiPackage(projectMsi)
                    );

                // ランタイムバンドルインストーラのバージョン
                bootstrapper.Version = new Version("1.0.0.0");

                // ランタイムバンドルインストーラのアップグレードコード (変更厳禁)
                bootstrapper.UpgradeCode = new Guid("bf3b1aeb-12c5-4401-ad23-6a49f905bd55");

                // ランタイムバンドルインストーラのアプリケーションスタイルの定義
                bootstrapper.Application             = new LicenseBootstrapperApplication();
                bootstrapper.Application.LicensePath = @".\Eula.rtf";

                bootstrapper.Application.LocalizationFile = "thm.wxl";

                // インストール時のOption非表示
                bootstrapper.Application.SuppressOptionsUI = true;
                // アンインストール時の修復を非表示
                bootstrapper.Application.SuppressRepair = true;

                // 一次領域を使用するか
                bootstrapper.PreserveTempFiles = true;
                // Wixの必須パラメータの定義?は行わない
                bootstrapper.SuppressWixMbaPrereqVars = false;

                // インストーラ名の定義
                bootstrapper.OutFileName = "ウィンドウズサービステスト_バンドルインストーラ";

                // ランタイムバンドルインストーラの作成
                bootstrapper.Build();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #14
0
        /// <summary>
        /// Analyses <paramref name="baseDirectory"/> and returns all files (including subdirectories) matching <see cref="Files.IncludeMask"/>.
        /// </summary>
        /// <param name="baseDirectory">The base directory for file analysis. It is used in conjunction with
        /// relative <see cref="Files.Directory"/>. Though <see cref="Files.Directory"/> takes precedence if it is an absolute path.</param>
        /// <returns>Array of <see cref="WixEntity"/> instances, which are either <see cref="File"/> or/and <see cref="Dir"/> objects.</returns>
        /// <param name="parentWixDir">Parent Wix# directory</param>
        // in anticipation of issues#48
        //public WixEntity[] GetAllItems(string baseDirectory)
        public WixEntity[] GetAllItems(string baseDirectory, Dir parentWixDir = null)
        {
            if (IO.Path.IsPathRooted(Directory))
            {
                baseDirectory = Directory;
            }
            if (baseDirectory.IsEmpty())
            {
                baseDirectory = Environment.CurrentDirectory;
            }

            baseDirectory = IO.Path.GetFullPath(baseDirectory);

            string rootDirPath;

            if (IO.Path.IsPathRooted(Directory))
            {
                rootDirPath = Directory;
            }
            else
            {
                rootDirPath = Utils.PathCombine(baseDirectory, Directory);
            }

            void AgregateSubDirs(Dir parentDir, string dirPath)
            {
                foreach (var subDirPath in IO.Directory.GetDirectories(dirPath))
                {
                    var dirName = IO.Path.GetFileName(subDirPath);

                    Dir subDir = parentDir.Dirs.FirstOrDefault(dir => dir.Name.SameAs(dirName, ignoreCase: true));

                    if (subDir == null)
                    {
                        subDir = new Dir(dirName);
                        parentDir.AddDir(subDir);
                    }

                    subDir.AddFeatures(this.ActualFeatures);
                    subDir.AddDirFileCollection(
                        new DirFiles(IO.Path.Combine(subDirPath, this.IncludeMask))
                    {
                        Feature              = this.Feature,
                        Features             = this.Features,
                        AttributesDefinition = this.AttributesDefinition,
                        Attributes           = this.Attributes,
                        Filter    = this.Filter,
                        OnProcess = this.OnProcess
                    });

                    AgregateSubDirs(subDir, subDirPath);
                }
            };

            var items = new List <WixEntity>
            {
                new DirFiles(IO.Path.Combine(rootDirPath, this.IncludeMask))
                {
                    Feature              = this.Feature,
                    Features             = this.Features,
                    AttributesDefinition = this.AttributesDefinition,
                    Attributes           = this.Attributes.Clone(),
                    Filter    = this.Filter,
                    OnProcess = this.OnProcess
                }
            };

            if (!IO.Directory.Exists(rootDirPath))
            {
                throw new IO.DirectoryNotFoundException(rootDirPath);
            }

            foreach (var subDirPath in System.IO.Directory.GetDirectories(rootDirPath))
            {
                var dirName = IO.Path.GetFileName(subDirPath);

                var subDir = parentWixDir?.Dirs.FirstOrDefault(dir => dir.Name.SameAs(dirName, ignoreCase: true));

                if (subDir == null)
                {
                    subDir = new Dir(dirName);
                    items.Add(subDir);
                }

                subDir.AddFeatures(this.ActualFeatures);
                subDir.AddDirFileCollection(
                    new DirFiles(IO.Path.Combine(subDirPath, this.IncludeMask))
                {
                    Feature              = this.Feature,
                    Features             = this.Features,
                    AttributesDefinition = this.AttributesDefinition,
                    Attributes           = this.Attributes,
                    Filter    = this.Filter,
                    OnProcess = this.OnProcess
                });

                AgregateSubDirs(subDir, subDirPath);
            }

            return(items.ToArray());
        }
Exemple #15
0
        static void ProcessDirectory(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents,
            List<string> defaultFeatureComponents, List<string> autoGeneratedComponents, XElement parent)
        {
            XElement dirItem = AddDir(parent, wDir);

            if (wDir.Files.Count() == 0 && wDir.Shortcuts.Count() == 0 && wDir.Dirs.Count() == 0 && wDir.Permissions.Count() == 0)
            {
                var existingCompElement = dirItem.Elements("Component");

                if (existingCompElement.Count() == 0)
                {
                    string compId = wDir.Id + ".EmptyDirectory";

                    if (wDir.Feature != null)
                    {
                        featureComponents.Map(wDir.Feature, compId);
                    }
                    else
                    {
                        defaultFeatureComponents.Add(compId);
                    }

                    dirItem.AddElement(
                        new XElement("Component",
                            new XAttribute("Id", compId),
                            new XAttribute("Guid", WixGuid.NewGuid(compId))));
                }


                //insert MergeModules
                ProcessMergeModules(wDir, dirItem, featureComponents, defaultFeatureComponents);

                foreach (Dir subDir in wDir.Dirs)
                    ProcessDirectory(subDir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirItem);

                return;
            }

            if (wDir.Feature != null)
            {
                string compId = "Component." + wDir.Id;
                featureComponents.Map(wDir.Feature, compId);
                dirItem.AddElement(
                        new XElement("Component",
                            new XAttribute("Id", compId),
                            new XAttribute("Guid", WixGuid.NewGuid(compId))));
            }

            #region Process Files

            //insert files in the last leaf directory node
            foreach (File wFile in wDir.Files)
            {
                string fileId = wFile.Id;
                string compId = "Component." + wFile.Id;

                if (wFile.Feature != null)
                {
                    featureComponents.Map(wFile.Feature, compId);
                }
                else
                {
                    defaultFeatureComponents.Add(compId);
                }

                XElement comp = dirItem.AddElement(
                    new XElement("Component",
                        new XAttribute("Id", compId),
                        new XAttribute("Guid", WixGuid.NewGuid(compId))));

                if (wFile.Condition != null)
                    comp.AddElement(
                        new XElement("Condition", new XCData(wFile.Condition.ToCData()))
                            .AddAttributes(wFile.Condition.Attributes));

                XElement file = comp.AddElement(
                    new XElement("File",
                        new XAttribute("Id", fileId),
                        new XAttribute("Source", Utils.PathCombine(wProject.SourceBaseDir, wFile.Name)))
                        .AddAttributes(wFile.Attributes));

                if (wFile.ServiceInstaller != null)
                    comp.Add(wFile.ServiceInstaller.ToXml(wProject));

                if (wFile is Assembly && (wFile as Assembly).RegisterInGAC)
                {
                    file.Add(new XAttribute("KeyPath", "yes"),
                             new XAttribute("Assembly", ".net"),
                             new XAttribute("AssemblyManifest", fileId),
                             new XAttribute("ProcessorArchitecture", ((Assembly)wFile).ProcessorArchitecture.ToString()));
                }

                //insert file associations
                foreach (FileAssociation wFileAssociation in wFile.Associations)
                {
                    XElement progId;
                    comp.Add(progId = new XElement("ProgId",
                                          new XAttribute("Id", wFileAssociation.Extension + ".file"),
                                          new XAttribute("Advertise", wFileAssociation.Advertise.ToYesNo()),
                                          new XAttribute("Description", wFileAssociation.Description),
                                          new XElement("Extension",
                                              new XAttribute("Id", wFileAssociation.Extension),
                                              new XAttribute("ContentType", wFileAssociation.ContentType),
                                              new XElement("Verb",
                                                  wFileAssociation.Advertise ?
                                                     new XAttribute("Sequence", wFileAssociation.SequenceNo) :
                                                     new XAttribute("TargetFile", fileId),
                                                  new XAttribute("Id", wFileAssociation.Command),
                                                  new XAttribute("Command", wFileAssociation.Command),
                                                  new XAttribute("Argument", wFileAssociation.Arguments)))));

                    if (wFileAssociation.Icon != null)
                    {
                        progId.Add(
                            new XAttribute("Icon", wFileAssociation.Icon != "" ? wFileAssociation.Icon : fileId),
                            new XAttribute("IconIndex", wFileAssociation.IconIndex));
                    }
                }

                //insert file owned shortcuts
                foreach (Shortcut wShortcut in wFile.Shortcuts)
                {
                    string locationDirId;

                    if (wShortcut.Location.IsEmpty())
                    {
                        locationDirId = wDir.Id;
                    }
                    else
                    {
                        Dir locationDir = wProject.FindDir(wShortcut.Location);

                        if (locationDir != null)
                        {
                            locationDirId = locationDir.Id;
                        }
                        else
                        {
                            if (!autogeneratedShortcutLocations.ContainsKey(wShortcut.Location))
                                autogeneratedShortcutLocations.Add(wShortcut.Location, wShortcut.Feature);

                            locationDirId = wShortcut.Location.Expand();
                        }
                    }

                    var shortcutElement =
                        new XElement("Shortcut",
                            new XAttribute("Id", "Shortcut." + wFile.Id + "." + wShortcut.Id),
                            new XAttribute("WorkingDirectory", !wShortcut.WorkingDirectory.IsEmpty() ? wShortcut.WorkingDirectory.Expand() : locationDirId),
                            new XAttribute("Directory", locationDirId),
                            new XAttribute("Name", wShortcut.Name.IsNullOrEmpty() ? IO.Path.GetFileNameWithoutExtension(wFile.Name) : wShortcut.Name + ".lnk"));

                    wShortcut.EmitAttributes(shortcutElement);

                    file.Add(shortcutElement);
                }

                //insert file related IIS virtual directories
                InsertIISElements(dirItem, comp, wFile.IISVirtualDirs, wProject);

                //insert file owned permissions
                ProcessFilePermissions(wProject, wFile, file);
            }

            #endregion

            #region Process Shorcuts

            //insert directory owned shortcuts
            foreach (Shortcut wShortcut in wDir.Shortcuts)
            {
                string compId = wShortcut.Id;
                if (wShortcut.Feature != null)
                {
                    if (!featureComponents.ContainsKey(wShortcut.Feature))
                        featureComponents[wShortcut.Feature] = new List<string>();

                    featureComponents[wShortcut.Feature].Add(compId);
                }
                else
                {
                    defaultFeatureComponents.Add(compId);
                }

                XElement comp = dirItem.AddElement(
                   new XElement("Component",
                       new XAttribute("Id", compId),
                       new XAttribute("Guid", WixGuid.NewGuid(compId))));

                if (wShortcut.Condition != null)
                    comp.AddElement(
                        new XElement("Condition", wShortcut.Condition.ToCData())
                            .AddAttributes(wShortcut.Condition.Attributes));

                XElement sc;
                sc = comp.AddElement(
                   new XElement("Shortcut",
                       new XAttribute("Id", wDir.Id + "." + wShortcut.Id),
                    //new XAttribute("Directory", wDir.Id), //not needed for Wix# as this attributed is required only if the shortcut is not nested under a Component element.
                       new XAttribute("WorkingDirectory", !wShortcut.WorkingDirectory.IsEmpty() ? wShortcut.WorkingDirectory.Expand() : GetShortcutWorkingDirectopry(wShortcut.Target)),
                       new XAttribute("Target", wShortcut.Target),
                       new XAttribute("Arguments", wShortcut.Arguments),
                       new XAttribute("Name", wShortcut.Name + ".lnk")));

                wShortcut.EmitAttributes(sc);
            }


            #endregion

            //insert MergeModules
            ProcessMergeModules(wDir, dirItem, featureComponents, defaultFeatureComponents);

            ProcessDirPermissions(wDir, wProject, featureComponents, defaultFeatureComponents, dirItem);

            foreach (Dir subDir in wDir.Dirs)
                ProcessDirectory(subDir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirItem);
        }
Exemple #16
0
        static void ProcessDirectory(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents,
            List<string> defaultFeatureComponents, List<string> autoGeneratedComponents, XElement parent)
        {
            XElement dirItem = AddDir(parent, wDir);

            bool isEmptyDir = wDir.Files.None() &&
                              wDir.Shortcuts.None() &&
                              wDir.Dirs.None() &&
                              wDir.MergeModules.None() &&
                              wDir.Permissions.None() &&
                              wDir.ODBCDataSources.None();

            if (isEmptyDir)
            {
                var existingCompElement = dirItem.Elements("Component");

                if (existingCompElement.Count() == 0)
                {
                    string compId = wDir.Id + ".EmptyDirectory";

                    if (wDir.Feature != null)
                    {
                        featureComponents.Map(wDir.Feature, compId);
                    }
                    else
                    {
                        defaultFeatureComponents.Add(compId);
                    }

                    dirItem.AddElement(
                        new XElement("Component",
                            new XAttribute("Id", compId),
                            new XAttribute("Guid", WixGuid.NewGuid(compId))));
                }
            }
            else
            {
                if (wDir.Feature != null)
                {
                    string compId = "Component." + wDir.Id;
                    featureComponents.Map(wDir.Feature, compId);
                    dirItem.AddElement(
                            new XElement("Component",
                                new XAttribute("Id", compId),
                                new XAttribute("Guid", WixGuid.NewGuid(compId))));
                }

                ProcessDirectoryFiles(wDir, wProject, featureComponents, defaultFeatureComponents, dirItem);
                ProcessDirectoryShortcuts(wDir, wProject, featureComponents, defaultFeatureComponents, dirItem);
                ProcessOdbcSources(wDir, wProject, featureComponents, defaultFeatureComponents, dirItem);
                ProcessMergeModules(wDir, dirItem, featureComponents, defaultFeatureComponents);
                ProcessDirPermissions(wDir, wProject, featureComponents, defaultFeatureComponents, dirItem);

                foreach (Dir subDir in wDir.Dirs)
                    ProcessDirectory(subDir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirItem);
            }
        }
Exemple #17
0
        private static void ProcessDirPermissions(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement dirItem)
        {
            if (wDir.Permissions.Any())
            {
                var utilExtension = WixExtension.Util;
                wProject.IncludeWixExtension(utilExtension);

                foreach (var permission in wDir.Permissions)
                {
                    string compId = "Component" + permission.Id;
                    if (permission.Feature != null)
                    {
                        if (!featureComponents.ContainsKey(permission.Feature))
                            featureComponents[permission.Feature] = new List<string>();

                        featureComponents[permission.Feature].Add(compId);
                    }
                    else
                    {
                        defaultFeatureComponents.Add(compId);
                    }

                    var permissionElement = new XElement(utilExtension.ToXNamespace() + "PermissionEx");
                    permission.EmitAttributes(permissionElement);
                    dirItem.Add(
                        new XElement("Component",
                            new XAttribute("Id", compId),
                            new XAttribute("Guid", WixGuid.NewGuid(compId)),
                            new XElement("CreateFolder",
                                permissionElement)));
                }
            }
        }
Exemple #18
0
        static void ProcessDirectoryFiles(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement dirItem)
        {
            //insert files in the last leaf directory node
            foreach (File wFile in wDir.Files)
            {
                string fileId = wFile.Id;
                string compId = "Component." + wFile.Id;

                if (wFile.Feature != null)
                {
                    featureComponents.Map(wFile.Feature, compId);
                }
                else
                {
                    defaultFeatureComponents.Add(compId);
                }

                XElement comp = dirItem.AddElement(
                    new XElement("Component",
                        new XAttribute("Id", compId),
                        new XAttribute("Guid", WixGuid.NewGuid(compId))));

                if (wFile.Condition != null)
                    comp.AddElement(
                        new XElement("Condition", new XCData(wFile.Condition.ToCData()))
                            .AddAttributes(wFile.Condition.Attributes));

                XElement file = comp.AddElement(
                    new XElement("File",
                        new XAttribute("Id", fileId),
                        new XAttribute("Source", Utils.PathCombine(wProject.SourceBaseDir, wFile.Name)))
                        .AddAttributes(wFile.Attributes));

                if (wFile.ServiceInstaller != null)
                    comp.Add(wFile.ServiceInstaller.ToXml(wProject));

                if (wFile is Assembly && (wFile as Assembly).RegisterInGAC)
                {
                    file.Add(new XAttribute("KeyPath", "yes"),
                             new XAttribute("Assembly", ".net"),
                             new XAttribute("AssemblyManifest", fileId),
                             new XAttribute("ProcessorArchitecture", ((Assembly)wFile).ProcessorArchitecture.ToString()));
                }

                wFile.DriverInstaller.Compile(wProject, comp);

                //insert file associations
                foreach (FileAssociation wFileAssociation in wFile.Associations)
                {
                    XElement progId;
                    comp.Add(progId = new XElement("ProgId",
                                          new XAttribute("Id", wFileAssociation.Extension + ".file"),
                                          new XAttribute("Advertise", wFileAssociation.Advertise.ToYesNo()),
                                          new XAttribute("Description", wFileAssociation.Description),
                                          new XElement("Extension",
                                              new XAttribute("Id", wFileAssociation.Extension),
                                              new XAttribute("ContentType", wFileAssociation.ContentType),
                                              new XElement("Verb",
                                                  wFileAssociation.Advertise ?
                                                     new XAttribute("Sequence", wFileAssociation.SequenceNo) :
                                                     new XAttribute("TargetFile", fileId),
                                                  new XAttribute("Id", wFileAssociation.Command),
                                                  new XAttribute("Command", wFileAssociation.Command),
                                                  new XAttribute("Argument", wFileAssociation.Arguments)))));

                    if (wFileAssociation.Icon != null)
                    {
                        progId.Add(
                            new XAttribute("Icon", wFileAssociation.Icon != "" ? wFileAssociation.Icon : fileId),
                            new XAttribute("IconIndex", wFileAssociation.IconIndex));
                    }
                }

                //insert file owned shortcuts
                foreach (Shortcut wShortcut in wFile.Shortcuts)
                {
                    string locationDirId;

                    if (wShortcut.Location.IsEmpty())
                    {
                        locationDirId = wDir.Id;
                    }
                    else
                    {
                        Dir locationDir = wProject.FindDir(wShortcut.Location);

                        if (locationDir != null)
                        {
                            locationDirId = locationDir.Id;
                        }
                        else
                        {
                            if (!autogeneratedShortcutLocations.ContainsKey(wShortcut.Location))
                                autogeneratedShortcutLocations.Add(wShortcut.Location, wShortcut.Feature);

                            locationDirId = wShortcut.Location.Expand();
                        }
                    }

                    var shortcutElement =
                        new XElement("Shortcut",
                            new XAttribute("Id", "Shortcut." + wFile.Id + "." + wShortcut.Id),
                            new XAttribute("WorkingDirectory", !wShortcut.WorkingDirectory.IsEmpty() ? wShortcut.WorkingDirectory.Expand() : locationDirId),
                            new XAttribute("Directory", locationDirId),
                            new XAttribute("Name", wShortcut.Name.IsNullOrEmpty() ? IO.Path.GetFileNameWithoutExtension(wFile.Name) : wShortcut.Name + ".lnk"));

                    wShortcut.EmitAttributes(shortcutElement);

                    file.Add(shortcutElement);
                }

                //insert file related IIS virtual directories
                InsertIISElements(dirItem, comp, wFile.IISVirtualDirs, wProject);

                //insert file owned permissions
                ProcessFilePermissions(wProject, wFile, file);
            }
        }
Exemple #19
0
        static void ProcessDirectories(Project wProject, Dictionary<Feature, List<string>> featureComponents,
            List<string> defaultFeatureComponents, List<string> autoGeneratedComponents, XElement dirs)
        {
            wProject.ResolveWildCards();

            if (wProject.Dirs.Count() == 0)
            {
                //WIX/MSI does not like no-directory deployments thus create fake one
                string dummyDir = @"%ProgramFiles%\WixSharp\DummyDir";
                if (wProject.Platform == Platform.x64)
                    dummyDir = dummyDir.Map64Dirs();

                wProject.Dirs = new[] { new Dir(dummyDir) };
            }

            Dir[] wDirs = wProject.Dirs;

            //auto-assign INSTALLDIR id for installation directory (the first directory that has multiple items)
            if (wDirs.Count() != 0)
            {
                Dir firstDirWithItems = wDirs.First();

                string logicalPath = firstDirWithItems.Name;
                while (firstDirWithItems.Shortcuts.Count() == 0 &&
                       firstDirWithItems.Dirs.Count() == 1 &&
                       firstDirWithItems.Files.Count() == 0)
                {
                    firstDirWithItems = firstDirWithItems.Dirs.First();
                    logicalPath += "\\" + firstDirWithItems.Name;
                }

                if (!firstDirWithItems.IsIdSet() && !Compiler.AutoGeneration.InstallDirDefaultId.IsEmpty())
                {
                    firstDirWithItems.Id = Compiler.AutoGeneration.InstallDirDefaultId;
                    wProject.AutoAssignedInstallDirPath = logicalPath;
                }
            }

            foreach (Dir wDir in wDirs)
            {
                ProcessDirectory(wDir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirs);
            }

            foreach (string dirPath in autogeneratedShortcutLocations.Keys)
            {
                Feature feature = autogeneratedShortcutLocations[dirPath];

                //be careful as some parts of the auto-generated director may already exist
                XElement existingParent = null;
                string dirToAdd = dirPath;
                string[] dirsToSearch = Dir.ToFlatPathTree(dirPath);
                foreach (string path in dirsToSearch)
                {
                    Dir d = wProject.FindDir(path);
                    if (d != null)
                    {
                        dirToAdd = dirPath.Substring(path.Length + 1);
                        existingParent = dirs.FindDirectory(path.ExpandWixEnvConsts());
                        break;
                    }
                }

                if (existingParent != null)
                {
                    Dir dir = new Dir(feature, dirToAdd);
                    ProcessDirectory(dir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, existingParent);
                }
                else
                {
                    Dir dir = new Dir(feature, dirPath);
                    ProcessDirectory(dir, wProject, featureComponents, defaultFeatureComponents, autoGeneratedComponents, dirs);
                }
            }
        }
Exemple #20
0
        static void ProcessDirectoryShortcuts(Dir wDir, Project wProject, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents, XElement dirItem)
        {
            //insert directory owned shortcuts
            foreach (Shortcut wShortcut in wDir.Shortcuts)
            {
                string compId = wShortcut.Id;
                if (wShortcut.Feature != null)
                {
                    if (!featureComponents.ContainsKey(wShortcut.Feature))
                        featureComponents[wShortcut.Feature] = new List<string>();

                    featureComponents[wShortcut.Feature].Add(compId);
                }
                else
                {
                    defaultFeatureComponents.Add(compId);
                }

                XElement comp = dirItem.AddElement(
                   new XElement("Component",
                       new XAttribute("Id", compId),
                       new XAttribute("Guid", WixGuid.NewGuid(compId))));

                if (wShortcut.Condition != null)
                    comp.AddElement(
                        new XElement("Condition", wShortcut.Condition.ToCData())
                            .AddAttributes(wShortcut.Condition.Attributes));

                XElement sc;
                sc = comp.AddElement(
                   new XElement("Shortcut",
                       new XAttribute("Id", wDir.Id + "." + wShortcut.Id),
                       //new XAttribute("Directory", wDir.Id), //not needed for Wix# as this attributed is required only if the shortcut is not nested under a Component element.
                       new XAttribute("WorkingDirectory", !wShortcut.WorkingDirectory.IsEmpty() ? wShortcut.WorkingDirectory.Expand() : GetShortcutWorkingDirectopry(wShortcut.Target)),
                       new XAttribute("Target", wShortcut.Target),
                       new XAttribute("Arguments", wShortcut.Arguments),
                       new XAttribute("Name", wShortcut.Name + ".lnk")));

                wShortcut.EmitAttributes(sc);
            }
        }
Exemple #21
0
        public static void Main(string[] args)
        {
            Feature appFeature = new Feature("Application files", "Main application files", true, false, @"INSTALLDIR");
            var shortcut = new FileShortcut(appFeature, "digiCamControl", @"%ProgramMenu%\digiCamControl") { WorkingDirectory = @"INSTALLDIR" };
            var shortcutD = new FileShortcut(appFeature, "digiCamControl", @"%Desktop%") { WorkingDirectory = @"INSTALLDIR" };
            var appDir = new Dir(@"digiCamControl",
                new File(appFeature, "CameraControl.exe", shortcut, shortcutD),
                new File(appFeature, "CameraControl.PluginManager.exe"),
                new File(appFeature, "CameraControlCmd.exe"),
                new File(appFeature, "CameraControlRemoteCmd.exe"),
                new File(appFeature, "dcraw.exe"),
                new File(appFeature, "ffmpeg.exe"),
                new File(appFeature, "ngrok.exe"),
                new File(appFeature, "MtpTester.exe"),
                //new File(appFeature, "PhotoBooth.exe",new FileShortcut(appFeature, "PhotoBooth", @"%ProgramMenu%\digiCamControl")),
                new DirFiles(appFeature, @"*.dll"),
            #if DEBUG
                new DirFiles(appFeature, @"*.pdb"),
            #endif
                new File(appFeature, "regwia.bat"),
                new File(appFeature, "logo.ico"),
                new File(appFeature, "logo_big.jpg"),
                new File(appFeature, "baseMtpDevice.xml"),
                new DirFiles(appFeature, @"*.png"),
                new File(appFeature, "DigiCamControl.xbs"),
                new Dir(appFeature, "Data",
                    new Files(appFeature, @"Data\*.*")),
                //new Dir(appFeature, "Plugins",
                //    new Files(appFeature, @"Plugins\*.*", "MahApps.Metro.*", "System.Windows.Interactivity.*",
                //        "WriteableBitmapEx.Wpf.*", "GalaSoft.MvvmLight.*", "*.config")),
                new Dir(appFeature, "Plugins",
                    new Dir(appFeature, "CameraControl.Plugins",
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\CameraControl.Plugins.dll"),
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\dcc.plugin")),
                    new Dir(appFeature, "Plugin.DeviceControlBox",
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\Plugin.DeviceControlBox.dll"),
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\dcc.plugin"))
                    ),
                new Dir(appFeature, "Languages",
                    new DirFiles(appFeature, @"Languages\*.xml")),
                new Dir(appFeature, "Licenses",
                    new DirFiles(appFeature, @"Licenses\*.*")),
                new Dir(appFeature, "x64",
                    new DirFiles(appFeature, @"x64\*.*")),
                new Dir(appFeature, "x86",
                    new DirFiles(appFeature, @"x86\*.*")),
                new Dir(appFeature, "Tools",
                    new DirFiles(appFeature, @"Tools\*.*")),
                new Dir(appFeature, "WebServer",
                    new Files(appFeature, @"WebServer\*.*"))
                );

            var baseDir = new Dir(@"%ProgramFiles%",
                appDir
                );

            Project project = new Project("digiCamControl",
                baseDir,
                new ManagedAction(Setup.CustomActions.MyAction, Return.ignore, When.Before, Step.InstallExecute,
                    Condition.NOT_Installed, Sequence.InstallExecuteSequence),
                new ManagedAction(Setup.CustomActions.SetRightAction, Return.ignore, When.Before, Step.InstallFinalize,
                    Condition.Always, Sequence.InstallExecuteSequence),
                new RegValue(appFeature, RegistryHive.ClassesRoot,
                    @"Wow6432Node\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{628C6DCD-6A0A-4804-AAF3-91335A83239B}",
                    "FriendlyName",
                    "digiCamControl Virtual WebCam"),
                new RegValue(appFeature, RegistryHive.CurrentUser,
                    @"SOFTWARE\IP Webcam",
                    "url",
                    "http://*****:*****@"SOFTWARE\IP Webcam",
                    "width","640"),
                new RegValue(appFeature, RegistryHive.CurrentUser,
                    @"SOFTWARE\IP Webcam",
                    "height", "426")
                );

            project.UI = WUI.WixUI_InstallDir;
            project.GUID = new Guid("19d12628-7654-4354-a305-9ab0932af676");
            //project.SetNetFxPrerequisite("NETFRAMEWORK45='#1'");

            #if DEBUG
            project.SourceBaseDir =
                Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Debug\"));
            #else
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Release\"));
            #endif
            /* Not particularly proud of this change, nor the matching one in ObsPluginSetup.cs, but it seems necessary to allow these
             * programs to be built regardless of the layout choosen for the files */
            FileVersionInfo ver = null;
            try
            {
                ver =
                    FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "CameraControl.exe"));
            }
            catch (FileNotFoundException ex)
            {
                project.SourceBaseDir = project.SourceBaseDir.Replace(@"Setup\bin\", "");
                ver =
                    FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "CameraControl.exe"));
            }

            project.LicenceFile = @"Licenses\DigiCamControlLicence.rtf";

            project.Version = new Version(ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            //project.MajorUpgradeStrategy.NewerProductInstalledErrorMessage = "A version of the digiCamControl already installed. Unistall it first from Control Panel !";
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;
            ////project.MajorUpgradeStrategy.UpgradeVersions = VersionRange.ThisAndOlder;
            ////project.MajorUpgradeStrategy.PreventDowngradingVersions = VersionRange.ThisAndOlder;

            project.ControlPanelInfo.Manufacturer = "Duka Istvan";
            project.OutFileName = string.Format("digiCamControlsetup_{0}", ver.FileVersion);
            project.ControlPanelInfo.ProductIcon = "logo.ico";
            if (System.IO.Directory.Exists(Path.Combine(project.SourceBaseDir, "Branding")))
            {
                appDir.AddDir(new Dir(appFeature, "Branding",
                    new Files(appFeature, @"Branding\*.*")));
            }

            string branding = Path.Combine(project.SourceBaseDir, "branding.xml");
            if (System.IO.File.Exists(branding))
            {
                var doc = new XmlDocument();
                doc.LoadXml(System.IO.File.ReadAllText(branding));
                string name = doc.DocumentElement.SelectSingleNode("/Branding/ApplicationTitle").InnerText;
                project.ControlPanelInfo.Manufacturer = name;
                project.OutFileName = string.Format(name.Replace(" ", "_") + "_{0}", ver.FileVersion);
                appDir.AddFile(new File(appFeature, "branding.xml"));
                project.Name = name;
                if (System.IO.File.Exists(Path.Combine(project.SourceBaseDir, "Branding", "logo.ico")))
                {
                    project.ControlPanelInfo.ProductIcon = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcut.IconFile = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcutD.IconFile = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcut.Name = name;
                    shortcutD.Name = name;
                }
                if (System.IO.File.Exists(Path.Combine(project.SourceBaseDir, "Branding", "Licence.rtf")))
                    project.LicenceFile = "Branding\\Licence.rtf";

            }
            project.InstallScope = InstallScope.perMachine;
            project.ResolveWildCards();
            Compiler.PreserveTempFiles = false;
            string productMsi = Compiler.BuildMsi(project);
            string obsMsi = ObsPluginSetup.Execute();
            Thread.Sleep(2000);
            var dict = new Dictionary<string, string>();
            dict.Add("Visible","yes");
            var bootstrapper =new Bundle(project.Name,
            new PackageGroupRef("NetFx46Web"),
            //new ExePackage("vcredist_x86.exe"){InstallCommand ="/quite" },
            new MsiPackage(Path.Combine(Path.GetDirectoryName(productMsi), "IPCamAdapter.msi")) { Permanent = false,Attributes = dict},
            new MsiPackage(obsMsi) { Id = "ObsPackageId", Attributes = dict },
            new MsiPackage(productMsi) { Id = "MyProductPackageId", DisplayInternalUI = true, Attributes = dict });

            bootstrapper.Copyright = project.ControlPanelInfo.Manufacturer;
            bootstrapper.Version = project.Version;
            bootstrapper.UpgradeCode = new Guid("19d12628-7654-4354-a305-3A2057E2E6C9");
            bootstrapper.DisableModify = "yes";
            bootstrapper.DisableRemove = true;
            //bootstrapper.Application = new LicenseBootstrapperApplication()
            //{
            //    LicensePath = Path.Combine(project.SourceBaseDir, project.LicenceFile),
            //    LogoFile = project.ControlPanelInfo.ProductIcon,

            //};
            bootstrapper.IconFile = project.ControlPanelInfo.ProductIcon;
            bootstrapper.PreserveTempFiles = true;
            bootstrapper.OutFileName = project.OutFileName;

            bootstrapper.Build();
        }
Exemple #22
0
        static void ProcessMergeModules(Dir wDir, XElement dirItem, Dictionary<Feature, List<string>> featureComponents, List<string> defaultFeatureComponents)
        {
            foreach (Merge msm in wDir.MergeModules)
            {
                XElement media = dirItem.Parent("Product").Select("Media");
                XElement package = dirItem.Parent("Product").Select("Package");

                string language = package.Attribute("Languages").Value; //note Wix# expects package.Attribute("Languages") to have a single value (yest it is a temporary limitation)
                string diskId = media.Attribute("Id").Value;

                XElement merge = dirItem.AddElement(
                    new XElement("Merge",
                        new XAttribute("Id", msm.Id),
                        new XAttribute("FileCompression", msm.FileCompression.ToYesNo()),
                        new XAttribute("Language", language),
                        new XAttribute("SourceFile", msm.SourceFile),
                        new XAttribute("DiskId", diskId))
                        .AddAttributes(msm.Attributes));

                //MSM features are very different as they are not associated with the component but with the merge module thus
                //it's not possible to add the feature 'child' MergeRef neither to featureComponents nor defaultFeatureComponents.
                //Instead we'll let PostProcessMsm to handle it because ProcessFeatures cannot do this. It will ignore this feature
                //as it has no nested elements.
                //Not elegant at all but works.
                //In the future it can be improved by allowing MergeRef to be added in the global collection featureMergeModules/DefaultfeatureComponents.
                //Then PostProcessMsm will not be needed.
                if (msm.Feature != null && !featureComponents.ContainsKey(msm.Feature))
                    featureComponents[msm.Feature] = new List<string>();
            }
        }
Exemple #23
0
        public static void Main(string[] args)
        {
            Feature appFeature = new Feature("Application files", "Main application files", true, false, @"INSTALLDIR");
            var shortcut = new FileShortcut(appFeature, "digiCamControl", @"%ProgramMenu%\digiCamControl") { WorkingDirectory = @"INSTALLDIR" };
            var shortcutD = new FileShortcut(appFeature, "digiCamControl", @"%Desktop%") { WorkingDirectory = @"INSTALLDIR" };
            var appDir = new Dir(@"digiCamControl",
                new File(appFeature, "CameraControl.exe", shortcut, shortcutD),
                new File(appFeature, "CameraControl.PluginManager.exe"),
                new File(appFeature, "CameraControlCmd.exe"),
                new File(appFeature, "CameraControlRemoteCmd.exe"),
                new File(appFeature, "dcraw.exe"),
                new File(appFeature, "ffmpeg.exe"),
                new File(appFeature, "ngrok.exe"),
                new File(appFeature, "MtpTester.exe"),
                //new File(appFeature, "PhotoBooth.exe",new FileShortcut(appFeature, "PhotoBooth", @"%ProgramMenu%\digiCamControl")),
                new DirFiles(appFeature, @"*.dll"),
            #if DEBUG
                new DirFiles(appFeature, @"*.pdb"),
            #endif
                new File(appFeature, "regwia.bat"),
                new File(appFeature, "logo.ico"),
                new File(appFeature, "logo_big.jpg"),
                new File(appFeature, "baseMtpDevice.xml"),
                new DirFiles(appFeature, @"*.png"),
                new File(appFeature, "DigiCamControl.xbs"),
                new Dir(appFeature, "Data",
                    new Files(appFeature, @"Data\*.*")),
                //new Dir(appFeature, "Plugins",
                //    new Files(appFeature, @"Plugins\*.*", "MahApps.Metro.*", "System.Windows.Interactivity.*",
                //        "WriteableBitmapEx.Wpf.*", "GalaSoft.MvvmLight.*", "*.config")),
                new Dir(appFeature, "Plugins",
                    new Dir(appFeature, "CameraControl.Plugins",
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\CameraControl.Plugins.dll"),
                        new File(appFeature, "Plugins\\CameraControl.Plugins\\dcc.plugin")),
                    new Dir(appFeature, "Plugin.DeviceControlBox",
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\Plugin.DeviceControlBox.dll"),
                        new File(appFeature, "Plugins\\Plugin.DeviceControlBox\\dcc.plugin"))
                    ),
                new Dir(appFeature, "Languages",
                    new DirFiles(appFeature, @"Languages\*.xml")),
                new Dir(appFeature, "Licenses",
                    new DirFiles(appFeature, @"Licenses\*.*")),
                new Dir(appFeature, "x64",
                    new DirFiles(appFeature, @"x64\*.*")),
                new Dir(appFeature, "x86",
                    new DirFiles(appFeature, @"x86\*.*")),
                new Dir(appFeature, "Tools",
                    new DirFiles(appFeature, @"Tools\*.*")),
                new Dir(appFeature, "WebServer",
                    new Files(appFeature, @"WebServer\*.*"))
                );

            var baseDir = new Dir(@"%ProgramFiles%",
                appDir
                );

            Project project = new Project("digiCamControl",
                baseDir,
                new ManagedAction(@"MyAction", Return.ignore, When.Before, Step.InstallExecute,
                    Condition.NOT_Installed, Sequence.InstallExecuteSequence),
                new ManagedAction(@"SetRightAction", Return.ignore, When.Before, Step.InstallFinalize,
                    Condition.Always, Sequence.InstallExecuteSequence)
                );

            project.UI = WUI.WixUI_InstallDir;
            project.GUID = new Guid("19d12628-7654-4354-a305-9ab0932af676");
            project.SetNetFxPrerequisite("NETFRAMEWORK40FULL='#1'");

            #if DEBUG
            project.SourceBaseDir =
                Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Debug\"));
            #else
            project.SourceBaseDir =
                Path.GetFullPath(System.IO.Path.Combine(Environment.CurrentDirectory, @"..\CameraControl\bin\Release\"));
            #endif

            FileVersionInfo ver =
                FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "CameraControl.exe"));

            project.LicenceFile = @"Licenses\DigiCamControlLicence.rtf";

            project.Version = new Version(ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart, ver.FilePrivatePart);
            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            //project.MajorUpgradeStrategy.NewerProductInstalledErrorMessage = "A version of the digiCamControl already installed. Unistall it first from Control Panel !";
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallInitialize;
            ////project.MajorUpgradeStrategy.UpgradeVersions = VersionRange.ThisAndOlder;
            ////project.MajorUpgradeStrategy.PreventDowngradingVersions = VersionRange.ThisAndOlder;

            project.ControlPanelInfo.Manufacturer = "Duka Istvan";
            project.OutFileName = string.Format("digiCamControlsetup_{0}", ver.FileVersion);
            project.ControlPanelInfo.ProductIcon = "logo.ico";
            if (System.IO.Directory.Exists(Path.Combine(project.SourceBaseDir, "Branding")))
            {
                appDir.AddDir(new Dir(appFeature, "Branding",
                    new Files(appFeature, @"Branding\*.*")));
            }

            string branding = Path.Combine(project.SourceBaseDir, "branding.xml");
            if (System.IO.File.Exists(branding))
            {
                var doc = new XmlDocument();
                doc.LoadXml(System.IO.File.ReadAllText(branding));
                string name = doc.DocumentElement.SelectSingleNode("/Branding/ApplicationTitle").InnerText;
                project.ControlPanelInfo.Manufacturer = name;
                project.OutFileName = string.Format(name.Replace(" ", "_") + "_{0}", ver.FileVersion);
                appDir.AddFile(new File(appFeature, "branding.xml"));
                project.Name = name;
                if (System.IO.File.Exists(Path.Combine(project.SourceBaseDir, "Branding", "logo.ico")))
                {
                    project.ControlPanelInfo.ProductIcon = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcut.IconFile = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcutD.IconFile = Path.Combine(project.SourceBaseDir, "Branding", "logo.ico");
                    shortcut.Name = name;
                    shortcutD.Name = name;
                }
                if (System.IO.File.Exists(Path.Combine(project.SourceBaseDir, "Branding", "Licence.rtf")))
                    project.ControlPanelInfo.ProductIcon = "Branding\\Licence.rtf";

            }

            project.ResolveWildCards();
            Compiler.PreserveTempFiles = true;
            Compiler.BuildMsi(project);
            ObsPluginSetup.Execute();
        }
Exemple #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dir"/> class with properties/fields initialized with specified parameters
 /// </summary>
 /// <param name="feature"><see cref="Feature"></see> the directory should be included in.</param>
 /// <param name="targetPath">The name of the directory. Note if the directory is a root installation directory <c>targetPath</c> must
 /// be specified as a full path. However if the directory is a nested installation directory the name must be a directory name only.</param>
 /// <param name="items">Any <see cref="WixEntity"/> which can be contained by directory (e.g. file, subdirectory).</param>
 public Dir(Feature feature, string targetPath, params WixEntity[] items)
 {
     lastDir = ProcessTargetPath(targetPath);
     lastDir.AddItems(items);
     lastDir.Feature = feature;
 }