Feature fSoftware = new Feature("< >"); Feature fPostgreSQL = new Feature(" PostgreSQL"); // , // , , fSoftware.Description = " "; fPostgreSQL.Description = " PostgreSQL";
var filesPath =Path.Combine( Path.GetFullPath( Path.Combine(System.Reflection.Assembly .GetExecutingAssembly().Location, @"..\..\..\")), "Files");
var project = new ManagedProject(" ", // Id , // Custom Actions new Dir(new Id("INSTALL_DIR"), @"%ProgramFiles%\< >", // new Files(fSoftware, Path.Combine( filesPath, @"< >\*.*"))), // PostgreSQL :\PostgreSQL // ( ) // new Dir("C:\PostgreSQL", // new WixSharp.File(fServer, Path.Combine(filesPath, @"postgresqlwin.exe")), // new WixSharp.File(fServer, Path.Combine(filesPath, @"database.backup")), // new WixSharp.File(fServer, Path.Combine(filesPath, @"pg_hba.conf")), // BAT- ( ) new WixSharp.File(fServer, Path.Combine(filesPath, @"installDB.bat"))) );
new InstalledFileAction("ReportViewer.exe", "/q", Return.asyncNoWait, When.After, Step.InstallFinalize, Condition.NOT_Installed)
# PostgreSQL SET PGPASSWORD=123456 # C:\PostgreSQL\bin\createdb.exe --host localhost --port 5432 --username "postgres" --no-password < > # C:\PostgreSQL\bin\pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname " " --role "postgres" --no-password --verbose "C:\PostgreSQL\database.backup"
project.ControlPanelInfo.Manufacturer = "< >"; project.GUID = new Guid("{F1CC4E21-0326-4107-BB5C-A834EAEF6DAE}"); project.LicenceFile = Path.Combine(filesPath, @"License.rtf"); project.UI = WUI.WixUI_Mondo; project.Language = "ru-RU"; project.OutFileName = "SetUp"; // .Net Framework 4.0 project.SetNetFxPrerequisite("NETFRAMEWORK40FULL >= '#1'", ", .NET Framework 4.0."); project.PreserveTempFiles = true; project.DefaultFeature = fSoftware; project.Version = new Version("1.0.0.1"); project.AfterInstall += AfterInstall; Compiler.BuildMsi(project);
private static void AfterInstall(SetupEventArgs e) { try { if ((e.Mode == SetupEventArgs.SetupMode.Installing) || (e.Mode == SetupEventArgs.SetupMode.Modifying)) { if (System.IO.File.Exists(@"C:\PostgreSQL\postgresqlwin.exe")) { var process = new Process(); process.StartInfo = new ProcessStartInfo(@"C:\PostgreSQL\postgresqlwin.exe", @"--prefix C:\PostgreSQL --mode unattended --datadir C:\PostgreSQL\data --superpassword 123456 --install_runtimes 0"); process.Start(); process.WaitForExit(); System.IO.File.Delete(@"C:\PostgreSQL\postgresqlwin.exe"); } if (System.IO.File.Exists(@"C:\PostgreSQL\pg_hba.conf")) { System.IO.File.Copy(@"C:\PostgreSQL\pg_hba.conf", @"C:\PostgreSQL\data\pg_hba.conf", true); System.IO.File.Delete(@"C:\PostgreSQL\pg_hba.conf"); } if (System.IO.File.Exists(@"C:\PostgreSQL\database.backup")) { if (System.IO.File.Exists(@"C:\PostgreSQL\installDB.bat")) { var pgProcess = new Process(); pgProcess.StartInfo = new ProcessStartInfo(@"C:\PostgreSQL\installDB.bat", "") { CreateNoWindow = true, UseShellExecute = false }; pgProcess.Start(); pgProcess.WaitForExit(); System.IO.File.Delete(@"C:\PostgreSQL\installDB.bat"); } else return; System.IO.File.Delete(@"C:\PostgreSQL\database.backup"); } } } catch (Exception ex) { System.Windows.MessageBox.Show(" : " + ex.ToString()); } }
new Dir(@"C:\Test1", ..), new Dir(@"C:\Test2", ..)
new Dir(@"C:\Test", new Dir(@"Test1", feature1), new Dir(@"Test2", feature2), )
Source: https://habr.com/ru/post/276175/
All Articles