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 File(@"Files\Docs\Manual.txt", new FilePermission("Everyone", GenericPermission.Read | GenericPermission.Execute), new FilePermission("Administrator") { Append = true, Delete = true, Write = true }), new Dir(@"Docs"), new Dir(@"Docs2", new DirPermission("Everyone", GenericPermission.All)), new Dir("Empty"))); project.UI = WUI.WixUI_InstallDir; project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.EmitConsistentPackageId = true; project.PreserveTempFiles = true; project.BuildMsi(); }
public static void Main(string[] args) { var project = new Project() { Name = "CustomActionTest", UI = WUI.WixUI_ProgressOnly, Dirs = new[] { new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"CSScriptLibrary.dll")) }, Actions = new[] { new PathFileAction(@"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe", "/u CSScriptLibrary", "INSTALLDIR", //or explicit ID of "new Dir(new Id("my_dir_id"), @"%ProgramFiles%\My..." Return.check, When.Before, Step.InstallFinalize, Condition.Installed), new PathFileAction(@"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe", "/i CSScriptLibrary.dll", "INSTALLDIR", //or explicit ID of "new Dir(new Id("my_dir_id"), @"%ProgramFiles%\My..." Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed), } }; project.BuildMsi(); }
static public void Main(string[] args) { Environment.SetEnvironmentVariable("bin", @"Files\Bin"); Environment.SetEnvironmentVariable("docs", @"Files\Docs"); Environment.SetEnvironmentVariable("LATEST_RELEASE", Environment.CurrentDirectory); var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"%bin%\MyApp.exe"), new Dir(@"Docs\Manual", new File(@"%docs%\Manual.txt"))), new EnvironmentVariable("MYPRODUCT_DIR", "[INSTALLDIR]"), new EnvironmentVariable("PATH", "[INSTALLDIR]") { Part = EnvVarPart.last }); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_InstallDir; project.RemoveDialogsBetween(Dialogs.WelcomeDlg, Dialogs.InstallDirDlg); project.OutDir = @"%LATEST_RELEASE%\MSI"; project.SourceBaseDir = "%LATEST_RELEASE%"; project.BuildMsi(); }
//The UI implementation is based on the work of BRYANPJOHNSTON //http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/ public static void Main(string[] args) { var productProj = new Project("My Product", new Dir(@"%ProgramFiles%\My Company\My Product", new File("readme.txt"))) { InstallScope = InstallScope.perMachine }; productProj.GUID = new Guid("6f330b47-2577-43ad-9095-1861bb258777"); string productMsi = productProj.BuildMsi(); //------------------------------------ var bootstrapper = new Bundle("My Product", new PackageGroupRef("NetFx40Web"), new MsiPackage(productMsi) { Id = "MyProductPackageId" }); bootstrapper.Version = new Version("1.0.0.0"); bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889a"); bootstrapper.Application = new ManagedBootstrapperApplication("%this%"); // you can also use System.Reflection.Assembly.GetExecutingAssembly().Location bootstrapper.PreserveTempFiles = true; bootstrapper.Build(); //io.File.Delete(productMsi); }
public static void Main(string[] args) { var binaries = new Feature("MyApp Binaries", "Application binaries"); var docs = new Feature("MyApp Documentation"); var tuts = new Feature("MyApp Tutorial"); docs.Add(tuts); binaries.Add(docs); var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(binaries, @"Files\Bin\MyApp.exe"), new Dir(@"Docs\Manual", new File(docs, @"Files\Docs\Manual.txt"), new File(tuts, @"Files\Docs\Tutorial.txt")))); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_FeatureTree; project.DefaultFeature = binaries; //this line is optional project.PreserveTempFiles = true; project.BuildMsi(); }
public static void Main(string[] args) { var productProj = new Project("My Product", new Dir(@"%ProgramFiles%\My Company\My Product", new File("readme.txt"))) { InstallScope = InstallScope.perMachine }; productProj.GUID = new Guid("6f330b47-2577-43ad-9095-1861bb258777"); productProj.LicenceFile = "License.rtf"; string productMsi = productProj.BuildMsi(); var bootstrapper = new Bundle("My Product Suite", new PackageGroupRef("NetFx40Web"), new MsiPackage(productMsi) { Id = "MyProductPackageId", DisplayInternalUI = true }); bootstrapper.Version = new Version("1.0.0.0"); bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889c"); bootstrapper.Application = new SilentBootstrapperApplication(); //use this custom BA to modify it's behavior to meet your requirements //bootstrapper.Application = new ManagedBootstrapperApplication("%this%"); bootstrapper.PreserveTempFiles = true; bootstrapper.Build(); }
static void BuildWithInclude(string package) { var project = new Project("CustomActionTest", new Binary(new Id("MyAction_File"), package)); project.AddXmlInclude("myaction.wxi"); project.BuildMsi(); }
public static void Main(string[] args) { var project = new Project("CustomActionTest", new ManagedAction("MyAction", Return.check, When.After, Step.InstallInitialize, Condition.NOT_Installed)); //project.Platform = Platform.x64; project.BuildMsi(); }
static void Main() { string ProjectName; Guid GUID; string Conf; #if DEBUG var IsDebug = true; #else var IsDebug = false; #endif if (IsDebug) { ProjectName = "GitTfsDebug"; GUID = new Guid("6FE30B47-2577-43AD-9095-1861BA25889B"); Conf = "Debug"; } else { ProjectName = "GitTfs"; GUID = new Guid("98823CC2-0C2E-4CF7-B5ED-EA2DD26559BF"); Conf = "Release"; } var SrcDir = @"..\GitTfs\bin\" + Conf; var project = new Project(ProjectName, new Dir(@"%ProgramFiles%\GitTfs", new Files("*.*", f => !f.EndsWith(".pdb") && !f.EndsWith(".xml") && !f.EndsWith(".rtf"))), new EnvironmentVariable("PATH", "[INSTALLDIR]") { Part = EnvVarPart.last }); project.UI = WUI.WixUI_InstallDir; project.GUID = GUID; project.SourceBaseDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, SrcDir)); FileVersionInfo fileinfo = FileVersionInfo.GetVersionInfo(Path.Combine(project.SourceBaseDir, "git-tfs.exe")); project.Version = new Version(fileinfo.FileMajorPart, fileinfo.FileMinorPart, fileinfo.FileBuildPart, fileinfo.FilePrivatePart); project.OutFileName = ProjectName + "-" + project.Version.ToString(); TxtToRtf(Path.Combine(project.SourceBaseDir, "LICENSE"), Path.Combine(project.SourceBaseDir, "LICENSE.rtf")); project.LicenceFile = @"LICENSE.rtf"; project.ControlPanelInfo.Manufacturer = "SEP"; //project.ControlPanelInfo.ProductIcon = "GitTfs.ico"; project.ControlPanelInfo.Comments = "A Git/TFS bridge, similar to git-svn"; project.ControlPanelInfo.HelpLink = "http://git-tfs.com/"; project.ControlPanelInfo.UrlUpdateInfo = "https://github.com/git-tfs/git-tfs/releases"; project.MajorUpgrade = new MajorUpgrade { Schedule = UpgradeSchedule.afterInstallInitialize, DowngradeErrorMessage = "A later version of GitTfs is already installed. Setup will now exit." }; project.BuildMsi(); }
static void Main() { var project = new Project("EmbeddedUI_Setup", new Dir(@"%ProgramFiles%\My Company\My Product", new File("readme.txt"))); project.EmbeddedUI = new EmbeddedAssembly(sys.Assembly.GetExecutingAssembly().Location); project.PreserveTempFiles = true; project.BuildMsi(); }
static void Main() { var project = new Project("PhotoSorter", new Dir(new Id("INSTALLDIR"), @"%LocalAppData%\PhotoSorter", new File(@"..\PhotoSorter\bin\Release\PhotoSorter.exe", new FileShortcut("PhotoSorter", @"%Desktop%"), new FileShortcut("PhotoSorter", @"%ProgramMenu%\PhotoSorter")), new Files(@"..\PhotoSorter\bin\Release\*.*", f => !f.EndsWith(".pdb") && !f.Contains("vshost") && !f.EndsWith("PhotoSorter.exe")), new ExeFileShortcut("Uninstall PhotoSorter", "[System64Folder]msiexec.exe", "/x [ProductCode]") { WorkingDirectory = "%Temp%" }) ); project.GUID = new Guid("{5E1EED8B-5CEB-4EE7-BD2D-B7A4BFA836C0}"); project.Codepage = "1251"; project.Language = "ru-RU"; project.SetVersionFromFile(@"..\PhotoSorter\bin\Release\PhotoSorter.exe"); project.Media.CompressionLevel = CompressionLevel.high; project.Media.EmbedCab = true; project.UI = WUI.WixUI_Common; project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default; project.InstallScope = InstallScope.perUser; var customUi = new CustomUI(); customUi.On(NativeDialogs.ExitDialog, Buttons.Finish, new CloseDialog() { Order = 9999 }); customUi.On(NativeDialogs.WelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.InstallDirDlg)); customUi.On(NativeDialogs.InstallDirDlg, Buttons.Back, new ShowDialog(NativeDialogs.WelcomeDlg)); customUi.On(NativeDialogs.InstallDirDlg, Buttons.Next, new SetTargetPath(), new ShowDialog(NativeDialogs.VerifyReadyDlg)); customUi.On(NativeDialogs.InstallDirDlg, Buttons.ChangeFolder, new SetProperty("_BrowseProperty", "[WIXUI_INSTALLDIR]"), new ShowDialog(CommonDialogs.BrowseDlg)); customUi.On(NativeDialogs.VerifyReadyDlg, Buttons.Back, new ShowDialog(NativeDialogs.InstallDirDlg, Condition.NOT_Installed), new ShowDialog(NativeDialogs.MaintenanceTypeDlg, Condition.Installed)); customUi.On(NativeDialogs.MaintenanceWelcomeDlg, Buttons.Next, new ShowDialog(NativeDialogs.MaintenanceTypeDlg)); customUi.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Back, new ShowDialog(NativeDialogs.MaintenanceWelcomeDlg)); customUi.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Repair, new ShowDialog(NativeDialogs.VerifyReadyDlg)); customUi.On(NativeDialogs.MaintenanceTypeDlg, Buttons.Remove, new ShowDialog(NativeDialogs.VerifyReadyDlg)); project.SetNetFxPrerequisite(Condition.Net45_Installed, "Please install .Net FrameWork 4.5"); project.CustomUI = customUi; project.OutFileName = "PhotoSorterSetup"; project.PreserveTempFiles = true; project.ResolveWildCards(true); project.BuildMsi(); }
public static void Main(string[] args) { var common = new Feature("Common Files"); var samples = new Feature("Samples"); var project = new Project("MyProduct", new Dir(common, @"%ProgramFiles%\My Company\My Product", new Dir(common, @"Docs\Manual"), new Dir(samples, @"Samples"))); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_FeatureTree; project.BuildMsi(); }
static void Main() { var project = new Project("MyProduct", new User("USER") { Domain = Environment.MachineName, //or a domain name your setup process has rights to add users to Password = "******", PasswordNeverExpires = true, CreateUser = true }); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_ProgressOnly; project.PreserveTempFiles = true; project.BuildMsi(); }
public static void Main(string[] args) { var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(@"Files\Bin\MyApp.exe")), //define users new User(new Id("MyOtherUser"), "James") { CreateUser = true, Password = "******"}, //define sql new SqlDatabase("MyDatabase0", ".\\SqlExpress", SqlDbOption.CreateOnInstall)); //new SqlString("alter login Bryce with password = '******'", ExecuteSql.OnInstall))); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.PreserveTempFiles = true; project.BuildMsi(); }
public static void Main(string[] args) { var productProj = new Project("My Product", new Dir(@"%ProgramFiles%\My Company\My Product", new File("readme.txt"))) { InstallScope = InstallScope.perUser }; //--------------------------------------------------------- var crtProj = new Project("CRT", new Dir(@"%ProgramFiles%\My Company\CRT", new File("readme.txt"))) { InstallScope = InstallScope.perUser }; //--------------------------------------------------------- string productMsi = productProj.BuildMsi(); string crtMsi = crtProj.BuildMsi(); //--------------------------------------------------------- var bootstrapper = new Bundle("My Product", new PackageGroupRef("NetFx40Web"), new MsiPackage(crtMsi) { DisplayInternalUI = true }, new MsiPackage(productMsi) { DisplayInternalUI = true }); bootstrapper.AboutUrl = "https://wixsharp.codeplex.com/"; bootstrapper.IconFile = "app_icon.ico"; bootstrapper.Version = new Version("1.0.0.0"); bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889b"); bootstrapper.Application.LogoFile = "logo.png"; bootstrapper.Application.LicensePath = "licence.html"; //HyperlinkLicense app with embedded license file //bootstrapper.Application.LicensePath = "licence.rtf"; //RtfLicense app with embedded license file //bootstrapper.Application.LicensePath = "http://opensource.org/licenses/MIT"; //HyperlinkLicense app with online license file //bootstrapper.Application.LicensePath = null; //HyperlinkLicense app with no license bootstrapper.PreserveTempFiles = true; bootstrapper.Build(); //--------------------------------------------------------- //if (io.File.Exists(productMsi)) // io.File.Delete(productMsi); if (io.File.Exists(crtMsi)) io.File.Delete(crtMsi); }
public static void Main(string[] args) { try { File service; var project = new Project("My Product", new Dir(@"%ProgramFiles%\My Company\My Product", service = new File(@"..\SimpleService\MyApp.exe"))); //The service file element can also be located as in the following commented code //File service = project.FindFile(f => f.Name.EndsWith("MyApp.exe")); //File service = project.AllFiles.Single(f => f.Name.EndsWith("MyApp.exe")); service.ServiceInstaller = new ServiceInstaller { Name = "WixSharp.TestSvc", DependsOn = "Dnscache;Dhcp", StartOn = SvcEvent.Install, StopOn = SvcEvent.InstallUninstall_Wait, RemoveOn = SvcEvent.Uninstall_Wait, DelayedAutoStart = true, ServiceSid = ServiceSid.none, FirstFailureActionType = FailureActionType.restart, SecondFailureActionType = FailureActionType.restart, ThirdFailureActionType = FailureActionType.runCommand, ProgramCommandLine = "MyApp.exe -run", RestartServiceDelayInSeconds = 30, ResetPeriodInDays = 1, PreShutdownDelay = 1000 * 60 * 3, RebootMessage = "Failure actions do not specify reboot", }; project.GUID = new Guid("6fe30b47-2577-43ad-9195-1861ba25889b"); project.OutFileName = "setup"; project.PreserveTempFiles = true; project.BuildMsi(); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { var project = new Project("My Product", new Dir(@"%ProgramFiles%\MyCompany", new Dir(@"MyWebApp", new File(@"MyWebApp\Default.aspx"), new File(@"MyWebApp\Default.aspx.cs"), new File(@"MyWebApp\Default.aspx.designer.cs"), new File(@"MyWebApp\Web.config")))); project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); project.IncludeWixExtension(WixExtension.IIs); project.WixSourceGenerated += Compiler_WixSourceGenerated; project.PreserveTempFiles = true; project.BuildMsi(); }
static void Main() { //NOTE: 'driver.sys' is a mock but not a real driver. Thus running msi will fail. var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Device", new File("driver.sys", new DriverInstaller { AddRemovePrograms = false, DeleteFiles = false, Legacy = true, PlugAndPlayPrompt = false, Sequence = 1, Architecture = DriverArchitecture.x64 }))); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.BuildMsi(); }
static public void Main(string[] args) { var project = new Project("My Product", new Dir(@"%ProgramFiles%\MyCompany", new Dir(@"MyWebApp", new File(@"MyWebApp\Default.aspx"), new File(@"MyWebApp\Default.aspx.cs"), new File(@"MyWebApp\Default.aspx.designer.cs"), new File(@"MyWebApp\Web.config")))); project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); project.WixExtensions.Add("WixIIsExtension.dll"); project.WixNamespaces.Add("xmlns:iis=\"http://schemas.microsoft.com/wix/IIsExtension\""); project.PreserveTempFiles = true; project.WixSourceGenerated += Compiler_WixSourceGenerated; project.BuildMsi(); }
static public void Main(string[] args) { //uncomment the line below if the reg file contains unsupported type to be ignored //RegFileImporter.SkipUnknownTypes = true; var fullSetup = new Feature("MyApp Binaries"); var project = new Project("MyProduct", new Dir(@"%ProgramFiles%\My Company\My Product", new File(fullSetup, @"readme.txt")), new RegFile(fullSetup, "MyProduct.reg"), //RegFile does the same Tasks.ImportRegFil new RegValue(fullSetup, RegistryHive.LocalMachine, "Software\\My Company\\My Product", "Message", "Hello"), new RegValue(fullSetup, RegistryHive.LocalMachine, "Software\\My Company\\My Product", "Count", 777), new RegValue(fullSetup, RegistryHive.ClassesRoot, "test\\shell\\open\\command", "", "\"[INSTALLDIR]test.exe\" \"%1\"")); project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_ProgressOnly; project.BuildMsi(); }
public static void Main(string[] args) { var project = new Project("MyProduct", new Dir(@"%ProgramFiles64Folder%\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"); //Note: setting x64 is done via XML injection for demo purposes only. //The x64 install can be achieved by "project.Platform = Platform.x64;" project.AddXmlInclude("CommonProperies.wxi") .AddXmlInclude("CommonProperies2.wxi"); //project specific build event project.WixSourceGenerated += InjectImages; //global build event Compiler.WixSourceGenerated += document => { document.Root.Select("Product/Package") .SetAttributeValue("Platform", "x64"); document.FindAll("Component") .ForEach(e => e.SetAttributeValue("Win64", "yes")); //merge 'Wix/Product' elements of document with 'Wix/Product' elements of CommonProperies.wxs document.InjectWxs("CommonProperies.wxs"); //document.Root.DescendantsAndSelf("Property").toList(); //the code below is the equivalent of project.AddXmlInclude(...) //document.FindSingle("Product").Add(new XProcessingInstruction("include", @"CommonProperies.wxi")); }; project.PreserveTempFiles = true; project.BuildMsi(); }
static public void Main(string[] args) { var productProj = new Project("My Product", new Dir(@"%ProgramFiles%\My Company\My Product", new File("readme.txt"))) { InstallScope = InstallScope.perUser }; productProj.GUID = new Guid("6f330b47-2577-43ad-9095-1861bb258777"); string productMsi = productProj.BuildMsi(); var bootstrapper = new Bundle("My Product", new PackageGroupRef("NetFx40Web"), new MsiPackage(productMsi) { DisplayInternalUI = true }); bootstrapper.Version = new Version("1.0.0.0"); bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889b"); bootstrapper.Application = new SilentBootstrapperApplication(); bootstrapper.PreserveTempFiles = true; bootstrapper.Build(); }
static string BuildUiPlayerResources() { var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"WixSharp\Demo_UIPlayer"); var result = Path.Combine(dir, "Demo_UIPlayer.msi"); if (System.IO.File.Exists(result)) { return(result); } else { try { Compiler.OutputWriteLine("Building UIPlayer resources..."); } catch { } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var project = new Project("Demo_UIPlayer", new Dir(@"%ProgramFiles%\WixSharp\Demo_UIPlayer")); project.OutDir = dir; string licence = ManagedUI.Default.LicenceFileFor(project); string localization = ManagedUI.Default.LocalizationFileFor(project); string bitmap = ManagedUI.Default.DialogBitmapFileFor(project); string banner = ManagedUI.Default.DialogBannerFileFor(project); project.AddBinaries(new Binary(new Id("WixSharp_UIText"), localization), new Binary(new Id("WixSharp_LicenceFile"), licence), new Binary(new Id("WixUI_Bmp_Dialog"), bitmap), new Binary(new Id("WixUI_Bmp_Banner"), banner)); project.UI = WUI.WixUI_ProgressOnly; return(project.BuildMsi()); } }
public static void Main(string[] args) { var project = new Project("My Product", new Dir(@"%ProgramFiles%\MyCompany", new Dir(@"MyWebApp", new File(@"MyWebApp\Default.aspx", new IISVirtualDir { Name = "MyWebApp", AppName = "Test", WebSite = new WebSite("DefaultWebSite", "*:80", "Default Web Site") { AttributesDefinition = "ConfigureIfExists=no" //uncomment and use the line below (instead above one) if you want the new WebSite to be created instead of existing one to be reused //,InstallWebSite = true } }), new File(@"MyWebApp\Default.aspx.cs"), new File(@"MyWebApp\Default.aspx.designer.cs"), new File(@"MyWebApp\Web.config")))); project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); project.UI = WUI.WixUI_ProgressOnly; project.OutFileName = "setup"; project.PreserveTempFiles = true; project.WixSourceGenerated += doc => { //ConfigureIfExists requires that webSite is contained by the Component not a Product element. So move it. var webSite = doc.FindSingle("WebSite"); var virtualDir = doc.FindSingle("WebVirtualDir"); webSite.MoveTo(virtualDir.Parent); }; project.BuildMsi(); }
/// <summary> /// Builds msi for SonarQube installation /// </summary> static string BuildSonarQubeMsi() { var project = new Project( // Project name "SonarQube", // Default installation location. new Dir(BootstrapperConstants.DefaultInstallDir, // File to be copied at installation location. new Files(@"SonarQube\*.*"), new WixSharp.File(new Id("sqljdbc64"), @"sqlauth\x64\sqljdbc_auth.dll") { Condition = "Msix64" }, new WixSharp.File(new Id("sqljdbc32"), @"sqlauth\x86\sqljdbc_auth.dll") { Condition = "NOT Msix64" }), new Dir(@"%Desktop%", new ExeFileShortcut("SonarQube", string.Format(@"[INSTALLDIR]\{0}\bin\windows-x86-64\StartSonar.bat", BootstrapperConstants.SonarQubeProductName), "") { Condition = new Condition("INSTALLSERVICE=\"NO\" AND Msix64"), WorkingDirectory = "[INSTALLDIR]" }, new ExeFileShortcut("SonarQube", string.Format(@"[INSTALLDIR]\{0}\bin\windows-x86-32\StartSonar.bat", BootstrapperConstants.SonarQubeProductName), "") { Condition = new Condition("INSTALLSERVICE=\"NO\" AND NOT Msix64"), WorkingDirectory = "[INSTALLDIR]" }), // Files not to be installed but required to be carried with MSI. These files are unpacked // as and when required in user's temp folder and removed after usage. new Binary(new Id("LicenseFile"), @"Resources\License.rtf"), new Binary(new Id("SonarQubeLogo"), @"Resources\sonarqube.png"), new Binary(new Id("NtRights"), @"tools\ntrights.exe"), // Properties to be carried to Execute sequence from UI sequence with their values persisted. new Property("SETUPTYPE", SetupType.Evaluation), new Property("PORT", BootstrapperConstants.DefaultSonarQubePort), new Property("INSTANCE", BootstrapperConstants.DefaultSqlInstance), new Property("SQLAUTHTYPE", AuthenticationType.Sql), new Property("INSTALLSERVICE", "YES"), new Property("DATABASEUSERNAME", "sonarqube"), new Property("DATABASEPASSWORD", "sonarqube"), new Property("DATABASENAME", "sonarqubedb"), new Property("CURRENTLOGGEDINUSER", "default"), new Property("DBENGINE", DbEngine.H2), new Property("DBPORT", "1433") ) { InstallScope = InstallScope.perMachine }; project.GUID = new Guid("c2dd93c3-bf14-41ef-a87d-2b75a195b446"); // Update InstallCustomActionsCount and UninstallCustomActionsCount in constants to // reflect the right progress during installation. // Progress is updated every time a message is received from a custom action. ElevatedManagedAction rollbackUnzipSonarQube = new ElevatedManagedAction(new Id("Action1.1"), "RollbackUnzipSonarQube", Return.ignore, When.After, Step.InstallFiles, Condition.NOT_Installed) { UsesProperties = "INSTALLDIR", Execute = Execute.rollback }; project.Actions = new WixSharp.Action[] { new ManagedAction(new Id("Action1.0"), "ChangeUserPrivilegesToLogOnAsService", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed) { Impersonate = true, UsesProperties = "SETUPTYPE,CURRENTLOGGEDINUSER" }, new SetPropertyAction(rollbackUnzipSonarQube.Id, "INSTALLDIR=[INSTALLDIR]", Return.check, When.After, Step.InstallInitialize, Condition.NOT_Installed), rollbackUnzipSonarQube, new ElevatedManagedAction(new Id("Action1.2"), "UnzipSonarQube", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed), new ElevatedManagedAction(new Id("Action1.3"), "SetSqlAuthInEnvironmentPath", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed) { Impersonate = true, UsesProperties = "SETUPTYPE" }, new ElevatedManagedAction(new Id("Action1.4"), "SetupSonarQubeConfiguration", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed) { UsesProperties = "SETUPTYPE,PORT,INSTANCE,SQLAUTHTYPE,INSTALLSERVICE,DATABASEUSERNAME,DATABASEPASSWORD,DATABASENAME,DBENGINE,DBPORT" } }; ElevatedManagedAction rollbackInstallSonarQubeService = new ElevatedManagedAction(new Id("Action1.5"), "RollbackInstallSonarQubeService", Return.ignore, When.After, Step.InstallFiles, Condition.NOT_Installed) { UsesProperties = "INSTALLDIR", Execute = Execute.rollback }; WixSharp.Action[] actions = new WixSharp.Action[] { new SetPropertyAction(rollbackInstallSonarQubeService.Id, "INSTALLDIR=[INSTALLDIR]", Return.check, When.After, Step.InstallInitialize, Condition.NOT_Installed), rollbackInstallSonarQubeService, new ElevatedManagedAction(new Id("Action1.6"), "InstallSonarQubeService", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed) { UsesProperties = "SETUPTYPE,SQLAUTHTYPE,INSTALLSERVICE,CURRENTLOGGEDINUSER,DBENGINE,DBPORT,PORT", Condition = new Condition("(NOT Installed AND INSTALLSERVICE=\"YES\")") }, new ElevatedManagedAction(new Id("Action1.7"), "StartSonarBatch", Return.check, When.After, Step.InstallFiles, Condition.NOT_Installed) { UsesProperties = "INSTALLSERVICE", Condition = new Condition("(NOT Installed AND INSTALLSERVICE=\"NO\")"), Impersonate = true }, new ElevatedManagedAction(new Id("Action1.8"), "UninstallSonarQubeService", Return.check, When.After, Step.RemoveFiles, Condition.Installed) { UsesProperties = "INSTALLSERVICE", Condition = new Condition("(Installed AND INSTALLSERVICE=\"YES\")") }, new ElevatedManagedAction(new Id("Action1.9"), "CleanSonarQubeInstallation", Return.check, When.After, Step.RemoveFiles, Condition.Installed) }; project.Actions = project.Actions.Concat<WixSharp.Action>(actions).ToArray<WixSharp.Action>(); project.Version = new Version(BootstrapperConstants.ProductVersion); project.MajorUpgrade = new MajorUpgrade() { DowngradeErrorMessage = "A later version of SonarQube is already installed on this machine", Schedule = UpgradeSchedule.afterInstallInitialize }; string msi = project.BuildMsi(); int exitCode = WixSharp.CommonTasks.Tasks.DigitalySign(msi, "SonarQubeInstaller.pfx", "http://timestamp.verisign.com/scripts/timstamp.dll", "password"); if (exitCode != 0) { Console.WriteLine("Could not sign the MSI file."); } else { Console.WriteLine("The MSI file was signed successfully."); } return msi; }
/// <summary> /// Builds msi for SQL installation. This msi just carries the sql express setup and /// expands it on installation. /// </summary> static string BuildSqlExpressMsi(string archType, Guid projectGuid) { string projectName = string.Format("SonarQube_SQLx{0}", archType); string sqlInstaller = string.Format(@"sqlexpress\SQLEXPR_x{0}_ENU.exe", archType); string binaryId = string.Format("SqlExpress{0}",archType); var project = new Project( // Project name projectName, // Default installation location. new Dir(BootstrapperConstants.DefaultInstallDir), // Files not to be installed but required to be carried with MSI. These files are unpacked // as and when required in user's temp folder and removed after usage. new Binary(new Id(binaryId), sqlInstaller), new Binary(new Id("ConfigurationFile"), @"sqlexpress\ConfigurationFile.ini") ) { InstallScope = InstallScope.perMachine }; project.GUID = projectGuid; project.Version = new Version(BootstrapperConstants.ProductVersion); project.MajorUpgrade = new MajorUpgrade() { DowngradeErrorMessage = "A later version of SonarQube is already installed on this machine", Schedule = UpgradeSchedule.afterInstallInitialize }; project.Actions = new WixSharp.Action[] { new ManagedAction("ExtractSqlExpress", Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed) }; string msi = project.BuildMsi(); int exitCode = WixSharp.CommonTasks.Tasks.DigitalySign(msi, "SonarQubeInstaller.pfx", "http://timestamp.verisign.com/scripts/timstamp.dll", "password"); if (exitCode != 0) { Console.WriteLine("Could not sign the MSI file."); } else { Console.WriteLine("The MSI file was signed successfully."); } return msi; }
static void BuildWithInjection(string package) { var project = new Project("CustomActionTest", new Binary(new Id("MyAction_File"), package)); project.WixSourceGenerated += document => { var product = document.Select("Wix/Product"); product.AddElement("CustomAction", @"Id=MyAction; BinaryKey=MyAction_File; DllEntry=MyAction; Impersonate=yes; Execute=immediate; Return=check"); var custom = product.SelectOrCreate("InstallExecuteSequence") .AddElement("Custom", "Action=MyAction;After=InstallInitialize", "(NOT Installed)"); }; project.BuildMsi(); }
public static void Main(string[] args) { try { Feature binaries = new Feature("MyApp Binaries"); Feature docs = new Feature("MyApp Documentation"); Project project = new Project("My Product", //Files and Shortcuts new Dir(@"%ProgramFiles%\My Company\My Product", new File(binaries, @"AppFiles\MyApp.exe", new FileShortcut(binaries, "MyApp", @"%ProgramMenu%\My Company\My Product"), new FileShortcut(binaries, "MyApp", @"%Desktop%")), new File(binaries, @"AppFiles\Registrator.exe"), new File(docs, @"AppFiles\Readme.txt"), new File(binaries, @"AppFiles\MyApp.ico"), new ExeFileShortcut(binaries, "Uninstall MyApp", "[System64Folder]msiexec.exe", "/x [ProductCode]")), new Dir("%Startup%", new ExeFileShortcut(binaries, "MyApp", "[INSTALLDIR]MyApp.exe", "")), new Dir(@"%ProgramMenu%\My Company\My Product", new ExeFileShortcut(binaries, "Uninstall MyApp", "[System64Folder]msiexec.exe", "/x [ProductCode]")), //Registries new RegValue(binaries, RegistryHive.LocalMachine, @"Software\My Product", "ExePath", @"[INSTALLDIR]MyApp.exe"), //Custom Actions new InstalledFileAction("Registrator.exe", "", Return.check, When.After, Step.InstallExecute, Condition.NOT_Installed), new InstalledFileAction("Registrator.exe", "/u", Return.check, When.Before, Step.InstallExecute, Condition.Installed), new ScriptAction(@"MsgBox ""Executing VBScript code...""", Return.ignore, When.After, Step.InstallFinalize, Condition.NOT_Installed), new ScriptFileAction(@"CustomActions\Sample.vbs", "Execute", Return.ignore, When.After, Step.InstallFinalize, Condition.NOT_Installed), new PathFileAction(@"%WindowsFolder%\notepad.exe", "readme.txt", @"INSTALLDIR", Return.asyncNoWait, When.After, Step.InstallFinalize, Condition.NOT_Installed), new ManagedAction(@"MyManagedAction", "%this%"), new InstalledFileAction("MyApp.exe", "")); project.GUID = new Guid("6fe30b47-2577-43ad-9095-1861ba25889b"); // or project.Id = Guid.NewGuid(); project.LicenceFile = @"AppFiles\License.rtf"; project.UI = WUI.WixUI_Mondo; project.SourceBaseDir = Environment.CurrentDirectory; project.OutFileName = "MyApp"; //project.PreserveTempFiles = true; project.WixSourceGenerated += Compiler_WixSourceGenerated; project.BuildMsi(); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }