Exemple #1
0
        static void Main(string[] args)
        {
            // User values

            Installer installer = new Installer(
                "OATC OpenMI Editor 2.0 Alpha X",
                "OpenMI Association Technical Committee",
                "2.0.0.0");

            DirectoryInfo dirInstaller = new DirectoryInfo(@"..\..\..\");
            DirectoryInfo dirBin       = new DirectoryInfo(Path.Combine(
                                                               dirInstaller.FullName, @"..\bin"));
            DirectoryInfo dirHelp = new DirectoryInfo(Path.Combine(
                                                          dirInstaller.FullName, @"..\Help"));
            DirectoryInfo dirExamples = new DirectoryInfo(Path.Combine(
                                                              dirInstaller.FullName, @"..\Help\examples"));
            DirectoryInfo dirExampleModels = new DirectoryInfo(Path.Combine(
                                                                   dirInstaller.FullName, @"..\Help\examples\models"));
            DirectoryInfo dirBitmaps = new DirectoryInfo(Path.Combine(
                                                             dirInstaller.FullName, @".\Bitmaps"));

            FileInfo[] programFilesFiles = new FileInfo[] {
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"OmiEd.ico")), // ico files should be first in this array
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"Oatc_OpenMI_ConfigurationEditor.exe")),
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"Oatc_OpenMI_Gui_Controls.dll")),
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"Oatc_OpenMI_Gui_Core.dll")),
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"Oatc.OpenMI.Sdk.dll")),
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"OpenMI.Standard2.dll")),
                new FileInfo(Path.Combine(dirBin.FullName,
                                          @"log4net.dll")),
                new FileInfo(Path.Combine(dirHelp.FullName,
                                          @"OpenMIEditorHelp_2_0.pdf")),
                new FileInfo(Path.Combine(dirHelp.FullName,
                                          @"OpenMIEditorHelp_2_0.chm")),
            };

            FileInfo[] desktopFolderFiles = new FileInfo[] {
                new FileInfo(Path.Combine(dirExamples.FullName,
                                          @"SimpleCSharpRiver2_RiverReach1.opr")),
                new FileInfo(Path.Combine(dirExamples.FullName,
                                          @"SimpleCSharpRiver2_RiverReachs1and2.opr")),
                new FileInfo(Path.Combine(dirExamples.FullName,
                                          @"SimpleCSharpRiver2_Decorators01.opr")),
                new FileInfo(Path.Combine(dirExamples.FullName,
                                          @"SimpleCSharpRiver2_Decorators02.opr")),
            };

            FileInfo[] desktopFolderSubFiles = new FileInfo[] {
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"Oatc.OpenMI.Sdk.dll")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"Oatc_OpenMI_Examples_SimpleCSharpRiver2.exe")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"Oatc_OpenMI_Sdk_ModelWrapper2.dll")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"OpenMI.Standard2.dll")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"SimpleCSharpRiver2_BoundaryConditions1.txt")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"SimpleCSharpRiver2_RiverReach1.omi")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"SimpleCSharpRiver2_RiverReach1.txt")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"SimpleCSharpRiver2_RiverReach2.omi")),
                new FileInfo(Path.Combine(dirExampleModels.FullName,
                                          @"SimpleCSharpRiver2_RiverReach2.txt")),
            };

            Shortcut[] shortcuts = new Shortcut[] {
                new Shortcut(
                    "Editor",
                    "OATC OpenMI Editor",
                    new FileInfo(Path.Combine(dirBin.FullName,
                                              @"Oatc_OpenMI_ConfigurationEditor.exe")),
                    @"Software\OpenMI\OATC_Editor"),
                new Shortcut(
                    "Help (PDF)",
                    "Help (PDF)",
                    new FileInfo(Path.Combine(dirHelp.FullName,
                                              @"OpenMIEditorHelp_2_0.pdf")),
                    @"Software\OpenMI\OATC_Editor"),
                new Shortcut(
                    "Help (CHM)",
                    "Help (CHM)",
                    new FileInfo(Path.Combine(dirHelp.FullName,
                                              @"OpenMIEditorHelp_2_0.chm")),
                    @"Software\OpenMI\OATC_Editor"),
            };

            Action[] actions = new Action[] {
                new Action(
                    "OpenMI OPR composition file",
                    new FileInfo(Path.Combine(dirBin.FullName,
                                              @"Oatc_OpenMI_ConfigurationEditor.exe")),
                    new FileInfo(Path.Combine(dirBin.FullName,
                                              @"OmiEd.ico")),
                    "opr",
                    "-opr \"%1\""),

                /*
                 * new Action(
                 * "OpenMI OMI Model file",
                 *      new FileInfo(Path.Combine(dirBin.FullName,
                 * @"Oatc_OpenMI_ConfigurationEditor.exe")),
                 * new FileInfo(Path.Combine(dirBin.FullName,
                 *      @"OmiEd.ico")),
                 * "omi",
                 * "-omi \"%1\""),
                 */
            };

            // Create WIX XML file

            installer.AddProgramFilesFiles("Editor", programFilesFiles);
            installer.AddDesktopFolderFiles("Examples", desktopFolderFiles);
            installer.AddDesktopFolderSubFiles("models", desktopFolderSubFiles);

            installer.AddShortcuts(shortcuts);
            installer.AddActions(actions);

            installer.AddLicenceFile(new FileInfo(Path.Combine(
                                                      dirInstaller.FullName, @"License.rtf")));

            installer.AddBitmapFiles(
                new FileInfo(Path.Combine(dirBitmaps.FullName, @"bannrbmp.bmp")),
                new FileInfo(Path.Combine(dirBitmaps.FullName, @"dlgbmp.bmp")));

            installer.WriteWix(new FileInfo(@"../../Editor.wxs"));

            Console.WriteLine("Press return to exit");
            Console.ReadLine();
        }