Esempio n. 1
0
        private static Dir GetDirContents(string prepend, string localPath, string folder, bool prependIsBase = true)
        {
            var localFolder = prependIsBase ? localPath + folder : localPath + prepend + folder;

            var dir = new Dir(prependIsBase ? prepend + folder : folder);

            foreach (var file in Directory.GetFiles(localFolder))
            {
                dir.AddFile(new WixSharp.File(file));
            }

            foreach (var directory in Directory.GetDirectories(localFolder).Select(d => new DirectoryInfo(d)))
            {
                dir.AddDir(GetDirContents(prependIsBase ? folder : prepend + "\\" + folder + "\\", localPath, directory.Name, false));
            }

            return(dir);
        }
Esempio n. 2
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),
                                          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

            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.LicenceFile = "Branding\\Licence.rtf";
                }
            }
            project.InstallScope = InstallScope.perMachine;
            project.ResolveWildCards();
            Compiler.PreserveTempFiles = false;
            string productMsi = Compiler.BuildMsi(project);
            string obsMsi     = ObsPluginSetup.Execute();

            var bootstrapper = new Bundle(project.Name,
                                          new PackageGroupRef("NetFx46Web"),
                                          new MsiPackage(Path.Combine(Path.GetDirectoryName(productMsi), "IPCamAdapter.msi")),
                                          new MsiPackage(obsMsi)
            {
                Id = "ObsPackageId",
            },
                                          new MsiPackage(productMsi)
            {
                Id = "MyProductPackageId",
            });
            bootstrapper.Copyright   = project.ControlPanelInfo.Manufacturer;
            bootstrapper.Version     = project.Version;
            bootstrapper.UpgradeCode = project.UpgradeCode.Value;
            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();
        }
Esempio n. 3
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, "imageJPlugin",
                                         //    new File(appFeature, "Plugins\\imageJPlugin\\imageJPlugin.dll"),
                                         //    new File(appFeature, "Plugins\\imageJPlugin\\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.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";

            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"));
                appDir.AddDir(new Dir(appFeature, "Branding",
                                      new DirFiles(appFeature, @"Branding\*.*")));
                project.Name = name;
            }

            Compiler.PreserveTempFiles = true;
            Compiler.BuildMsi(project);
        }
Esempio n. 4
0
        private static void BuildSetupPackage(bool is64Bit, string projectGuid)
        {
            string  productTitle             = String.Format(Constants.PRODUCT_TITLE_FORMAT, is64Bit ? 64 : 32);
            string  shortcutTitle            = String.Format(Constants.SHORTCUT_TITLE_FORMAT, is64Bit ? 64 : 32);
            string  normalizedCurrentVersion = Constants.CURRENT_VERSION.Count(c => c == '.') > 1 ? Constants.CURRENT_VERSION : Constants.CURRENT_VERSION + ".0";
            string  installerFileName        = String.Format(Constants.INSTALLER_FILE_NAME_FORMAT, is64Bit ? 64 : 32);
            Project project       = new Project(productTitle, new Dir(@"%ProgramFiles%\Libgen Desktop"));
            Dir     rootDirectory = project.Dirs.First().Dirs.First();
            Dictionary <string, List <AppFile> > appFiles = GetAppFiles(is64Bit);

            foreach (string subDirectoryName in appFiles.Keys)
            {
                Dir directory;
                if (String.IsNullOrEmpty(subDirectoryName))
                {
                    directory = rootDirectory;
                }
                else
                {
                    directory = new Dir(subDirectoryName);
                    rootDirectory.AddDir(directory);
                }
                foreach (AppFile appFile in appFiles[subDirectoryName])
                {
                    string filePath = Utils.GetFullFilePath(AppFiles.GetBinariesDirectoryPath(is64Bit), appFile.SourceFilePath);
                    File   file     = new File(filePath);
                    if (appFile.SourceFilePath == Constants.MAIN_EXECUTABLE_NAME)
                    {
                        file.Shortcuts = new[]
                        {
                            new FileShortcut(shortcutTitle, "%ProgramMenu%")
                        };
                    }
                    directory.AddFile(file);
                }
            }
            project.GUID = new Guid(projectGuid);
            project.ControlPanelInfo.Manufacturer = Constants.PRODUCT_COMPANY;
            project.ControlPanelInfo.ProductIcon  = Constants.APP_ICON_PATH;
            project.Version = new Version(Constants.CURRENT_VERSION);
            project.MajorUpgradeStrategy = new MajorUpgradeStrategy
            {
                UpgradeVersions = new VersionRange
                {
                    Minimum        = "0.0.0",
                    Maximum        = normalizedCurrentVersion,
                    IncludeMinimum = true,
                    IncludeMaximum = false
                },
                PreventDowngradingVersions = new VersionRange
                {
                    Minimum        = normalizedCurrentVersion,
                    IncludeMinimum = false
                },
                NewerProductInstalledErrorMessage = "Newer version is already installed."
            };
            project.SetNetFxPrerequisite("WIX_IS_NETFRAMEWORK_45_OR_LATER_INSTALLED", ".NET Framework 4.5 or newer must be installed first. You can download it at http://dot.net.");
            project.Platform     = is64Bit ? Platform.x64 : Platform.x86;
            project.InstallScope = InstallScope.perMachine;
            project.UI           = WUI.WixUI_InstallDir;
            project.CustomUI     = new DialogSequence()
                                   .On(NativeDialogs.WelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.InstallDirDlg))
                                   .On(NativeDialogs.InstallDirDlg, Buttons.Back, new ShowDialog(NativeDialogs.WelcomeDlg));
            project.BuildMsi(installerFileName);
            Utils.MoveFile($"{installerFileName}.msi", @"..\Release");
        }
Esempio n. 5
0
        public void Push(ref Context context, string src, string dest)
        {
            bool srcEndsWithSeparator = OSPath.IsPathSeparator(src.Last());

            // src is a local file system path, thus, use the Path and the OSPath classes
            src = Path.GetFullPath(OSPath.Clean(src));

            FileAttributes fa = File.GetAttributes(src);
            Queue <Tuple <string, string> > queue = new Queue <Tuple <string, string> >();

            if ((fa & FileAttributes.Directory) == FileAttributes.Directory)
            {
                // src is a folder, let's define the desired behaviour, following
                // the design of rsync:
                //
                // cync push c:/home/user/documents/ /user/documents
                //    Content of c:/home/user/documents goes into /user/documents
                //
                // cync push c:/home/user/documents /user/documents
                //    Content of c:/home/user/documents goes into /user/documents/documents
                //
                // Notice the difference caused by the presence/lack of the final
                // directory separator (slash in the above example) in the source
                // (documents/ vs just documents).

                if (srcEndsWithSeparator)
                {
                    string fullDestPath = dest;
                    queue.Enqueue(Tuple.Create(src, fullDestPath));
                    context.InfoWriteLine($"Queueing directory '{src}' [target: '{fullDestPath}']");
                }
                else
                {
                    string fullDestPath = LexicalPath.Combine(dest, Path.GetFileName(src));
                    queue.Enqueue(Tuple.Create(src, fullDestPath));
                    context.InfoWriteLine($"Queueing directory '{src}' [target: '{fullDestPath}']");
                }

                // Compute total size
                var sizeQueue = new Queue <string>(queue.Select(t => t.Item1).ToList());
                var totalSize = 0L;
                while (sizeQueue.Count > 0)
                {
                    var path = sizeQueue.Dequeue();
                    foreach (var ee in Directory.EnumerateFileSystemEntries(path))
                    {
                        FileInfo fi = new FileInfo(ee);
                        if ((fi.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
                        {
                            sizeQueue.Enqueue(ee);
                        }
                        else
                        {
                            totalSize += fi.Length;
                        }
                    }
                }

                var progress       = new ProgressBar(totalSize, flush: true);
                var processedBytes = 0L;

                // Process the queue
                while (queue.Count > 0)
                {
                    var tt = queue.Dequeue();

                    // Process all directory entries. Files are added to the repo directly,
                    // sub directories are queued for further processing.
                    var entries = Directory.EnumerateFileSystemEntries(tt.Item1);

                    // Create the path if it doesn't exist
                    Dir curDestDir = Dir.Open(ref context, LexicalPath.GetDirectoryName(tt.Item2), true);
                    if (tt.Item2.Length > 0 && tt.Item2 != "/")
                    {
                        string destPath = LexicalPath.GetFileName(tt.Item2);
                        if (!curDestDir.HasEntry(destPath))
                        {
                            curDestDir.AddDir(destPath, tt.Item1);
                        }
                        curDestDir.ChangeDirDown(destPath);
                    }

                    foreach (var ee in entries)
                    {
                        FileInfo fi = new FileInfo(ee);
                        if ((fi.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
                        {
                            // Enque the directory for later processing
                            var destFullPath = LexicalPath.Combine(tt.Item2, Path.GetFileName(ee));
                            queue.Enqueue(Tuple.Create(ee, destFullPath));
                            context.InfoWriteLine($"Queueing directory '{ee}' [target: '{destFullPath}']");
                        }
                        else
                        {
                            if (!context.Verbose)
                            {
                                progress.Text = $"Processing '{ee}'";
                                progress.Update(processedBytes);
                            }

                            // A file - copy it
                            var added = curDestDir.PushFile(ee, Path.GetFileName(ee), false);
                            if (added)
                            {
                                context.InfoWriteLine($"Added '{ee}' as '{LexicalPath.Combine(tt.Item2, Path.GetFileName(ee))}'");
                            }
                            else
                            {
                                context.InfoWriteLine($"Skipped '{ee}'. The repository file '{LexicalPath.Combine(tt.Item2, Path.GetFileName(ee))}' is newer or the same.");
                            }

                            processedBytes += fi.Length;
                        }
                    }
                }

                if (!context.Verbose)
                {
                    progress.Text = "";
                    progress.Update(processedBytes);
                }
            }
        }