public ExePackage Build(Bundle bootstrapper) { const string nameForNetFx45Release = "NETFRAMEWORK45"; bootstrapper.IncludeWixExtension(WixExtension.Util); var netFx40RelaseRegistrySearch = new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", Value = "Release", Result = SearchResult.value, Format = SearchFormat.raw, Variable = nameForNetFx45Release, }; bootstrapper.AddWixFragment("Wix/Bundle", netFx40RelaseRegistrySearch); var isInstalledCondition = $"{nameForNetFx45Release} >= 394254"; var package = new ExePackage(@"..\redist\NDP461-KB3102438-Web.exe") { Name = "Microsoft .NET Framework 4.6.1", Description = "Microsoft .NET Framework 4.6.1 Setup", Compressed = true, DownloadUrl = "https://download.microsoft.com/download/3/5/9/35980F81-60F4-4DE3-88FC-8F962B97253B/NDP461-KB3102438-Web.exe", //Name = "NDP461-KB3102438-Web.exe", //SourceFile = "NDP461-KB3102438-Web.exe", Vital = true, PerMachine = true, Permanent = true, //ExitCodes = new List<ExitCode>() { new ExitCode(){Value = "1641",Behavior = BehaviorValues.scheduleReboot}, new ExitCode() { Value = "3010", Behavior = BehaviorValues.scheduleReboot } }, InstallCommand = "/q /norestart", DetectCondition = $"{isInstalledCondition}", InstallCondition = $"(VersionNT >= v6.0) AND (NOT ({isInstalledCondition}))", }; return(package); }
public ExePackage Build(Bundle bootstrapper) { const string variableNameForNetFx40 = "NETFRAMEWORK40"; bootstrapper.IncludeWixExtension(WixExtension.Util); var netFx40RegistrySearch = new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", Value = "Install", Result = SearchResult.value, Format = SearchFormat.raw, Variable = variableNameForNetFx40, }; bootstrapper.AddWixFragment("Wix/Bundle", netFx40RegistrySearch); var package = new ExePackage(@"..\redist\dotNetFx40_Full_setup.exe") { Name = "Microsoft .NET Framework 4", Description = "Microsoft .NET Framework 4 Setup", Compressed = true, DownloadUrl = "https://download.microsoft.com/download/1/B/E/1BE39E79-7E39-46A3-96FF-047F95396215/dotNetFx40_Full_setup.exe", //Name = "dotNetFx40_Full_setup.exe", //SourceFile = "dotNetFx40_Full_setup.exe", Vital = true, PerMachine = true, Permanent = true, //ExitCodes = new List<ExitCode>() { new ExitCode(){Value = "1641",Behavior = BehaviorValues.scheduleReboot}, new ExitCode() { Value = "3010", Behavior = BehaviorValues.scheduleReboot } }, InstallCommand = "/q /norestart", DetectCondition = $"({variableNameForNetFx40}) OR (VersionNT >= v6.0)", InstallCondition = $"(VersionNT < v6.0) AND (NOT {variableNameForNetFx40})", }; return(package); }
static public void Main(string[] args) { string productMsi = BuildMainMsi(); string crtMsi = BuildCrtMsi(); //--------------------------------------------------------- var msiOnlinePackage = new MsiPackage(crtMsi) //demo for downloadable msi package { Vital = true, Compressed = false, DisplayInternalUI = true, DownloadUrl = @"https://dl.dropboxusercontent.com/....../CRT.msi" }; var bootstrapper = new Bundle("My Product", new PackageGroupRef("NetFx40Web"), //new ExePackage(@"..\redist\dotNetFx40_Full_x86_x64.exe") //just a demo sample //{ // Name = "Microsoft .NET Framework 4.0", // InstallCommand = "/passive /norestart", // Permanent = true, // Vital = true, // DetectCondition = "Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)", // Compressed = true //}, //msiOnlinePackage, //just a demo sample new MsiPackage(crtMsi) { DisplayInternalUI = true, MsiProperties = "PACKAGE_PROPERTY=[BundleVariable]" }, new MsiPackage(productMsi) { DisplayInternalUI = true }); bootstrapper.AboutUrl = "https://wixsharp.codeplex.com/"; bootstrapper.IconFile = "app_icon.ico"; bootstrapper.Version = Tasks.GetVersionFromFile(productMsi); //will extract "product version" 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.IncludeWixExtension(WixExtension.Util); // The code below sets WiX variables 'Netfx4FullVersion' and 'AdobeInstalled'. Note it has no affect on //the runtime behavior and use of 'FileSearch' and "RegistrySearch" only provided as an example. bootstrapper.AddWixFragment("Wix/Bundle", new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"Key=SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full", Value = "Version", Variable = "Netfx4FullVersion" }, new UtilFileSearch { Path = @"[ProgramFilesFolder]Adobe\adobe.exe", Result = SearchResult.exists, Variable = "AdobeInstalled" }); bootstrapper.StringVariablesDefinition += "BundleVariable=333"; bootstrapper.PreserveTempFiles = true; // Add MspPackage manually (demo only). // In the future releases the direct support for MspPackage element will be added. // bootstrapper.WixSourceGenerated += (doc) => doc.FindSingle("Chain") // .AddElement("MspPackage", // "SourceFile=Patch.msp; Slipstream=no"); //in real life scenarios suppression may need to be enabled (see SuppressWixMbaPrereqVars documentation) //bootstrapper.SuppressWixMbaPrereqVars = true; var setup = bootstrapper.Build("app_setup"); //--------------------------------------------------------- if (io.File.Exists(productMsi)) { io.File.Delete(productMsi); } if (io.File.Exists(crtMsi)) { io.File.Delete(crtMsi); } }
static public void Main() { string productMsi = BuildMainMsi(); string crtMsi = BuildCrtMsi(); //--------------------------------------------------------- var msiOnlinePackage = new MsiPackage(crtMsi) //demo for downloadable msi package { Vital = true, Compressed = false, DisplayInternalUI = true, DownloadUrl = @"https://dl.dropboxusercontent.com/....../CRT.msi" }; // Compiler.AutoGeneration.SuppressForBundleUndefinedIds = false; // Compiler.AutoGeneration.LegacyDefaultIdAlgorithm = false; var bootstrapper = new Bundle("My Product", new PackageGroupRef("NetFx40Web"), //new ExePackage(@"..\redist\dotNetFx40_Full_x86_x64.exe") //just a demo sample //{ // Name = "Microsoft .NET Framework 4.0", // InstallCommand = "/passive /norestart", // Permanent = true, // Vital = true, // DetectCondition = "Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)", // Compressed = true //}, //msiOnlinePackage, //just a demo sample new MsiPackage(crtMsi) { DisplayInternalUI = true, Visible = true, MsiProperties = "PACKAGE_PROPERTY=[BundleVariable]" }, new MsiPackage(productMsi) { DisplayInternalUI = true, Payloads = new[] { "script.dll".ToPayload() } }); bootstrapper.AboutUrl = "https://github.com/oleg-shilo/wixsharp/"; bootstrapper.IconFile = "app_icon.ico"; bootstrapper.Version = Tasks.GetVersionFromFile(productMsi); //will extract "product version" bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889b"); bootstrapper.Application.LogoFile = "logo.png"; bootstrapper.Application.Payloads = new[] { "logo.png".ToPayload() }; // adding themes // var themes = new[] // { // new Payload("managedsetup.wxl") { Name = "1033\thm.wxl" } // }; // bootstrapper.Application.Payloads = themes; 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.Application.AttributesDefinition = "ShowVersion=yes; ShowFilesInUse=yes"; bootstrapper.Include(WixExtension.Util); bootstrapper.IncludeWixExtension(@"WixDependencyExtension.dll", "dep", "http://schemas.microsoft.com/wix/DependencyExtension"); bootstrapper.AttributesDefinition = "{dep}ProviderKey=01234567-8901-2345-6789-012345678901"; // The code below sets WiX variables 'Netfx4FullVersion' and 'AdobeInstalled'. Note it has no affect on //the runtime behaviour and 'FileSearch' and "RegistrySearch" are only provided as an example. bootstrapper.AddWixFragment("Wix/Bundle", new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full", Value = "Version", Variable = "Netfx4FullVersion" }, new UtilFileSearch { Path = @"[ProgramFilesFolder]Adobe\adobe.exe", Result = SearchResult.exists, Variable = "AdobeInstalled" }); // bootstrapper.AddXml("Wix/Bundle", "<Log PathVariable=\"LogFileLocation\"/>"); bootstrapper.AddXmlElement("Wix/Bundle", "Log", "PathVariable=LogFileLocation"); bootstrapper.Variables = new[] { new Variable("LogFileLocation", @"C:\temp\setup.log") { Overridable = true } }; // or // bootstrapper.Variables = "BundleVariable=333".ToStringVariables(); // bootstrapper.Variables = Variables.ToStringVariables("BundleVariable=333"); bootstrapper.PreserveTempFiles = true; // Add MspPackage manually (demo only). // In the future releases the direct support for MspPackage element will be added. // bootstrapper.WixSourceGenerated += (doc) => doc.FindSingle("Chain") // .AddElement("MspPackage", // "SourceFile=Patch.msp; Slipstream=no"); // bootstrapper.WixSourceGenerated += doc => doc.FindSingle("WixStandardBootstrapperApplication") // .AddAttributes("ShowVersion=yes; ShowFilesInUse=no"); //in real life scenarios suppression may need to be enabled (see SuppressWixMbaPrereqVars documentation) //bootstrapper.SuppressWixMbaPrereqVars = true; var setup = bootstrapper.Build("app_setup"); Console.WriteLine(setup); //--------------------------------------------------------- if (io.File.Exists(productMsi)) { io.File.Delete(productMsi); } if (io.File.Exists(crtMsi)) { io.File.Delete(crtMsi); } }
public ExePackage[] Build(Bundle bootstrapper) { const string variableNameForX86 = "KB2468871x86Installed"; const string variableNameForX64 = "KB2468871x64Installed"; bootstrapper.IncludeWixExtension(WixExtension.Util); var kb468871X86RegistrySearch = new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\Updates\Microsoft .NET Framework 4 Extended\KB2468871", Result = SearchResult.exists, Format = SearchFormat.raw, Win64 = false, Variable = variableNameForX86, }; var kb2468871X64RegistrySearch = new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\Updates\Microsoft .NET Framework 4 Extended\KB2468871",//SOFTWARE\wow6432node\Microsoft\Updates\Microsoft .NET Framework 4 Extended\KB2468871 Result = SearchResult.exists, Format = SearchFormat.raw, Win64 = true, Variable = variableNameForX64, }; bootstrapper.AddWixFragment("Wix/Bundle", kb468871X86RegistrySearch, kb2468871X64RegistrySearch); //TODO: those packages binaries should not be included in repo //DownloadUrl should make it downloadable from web during build time _kb2468871X64Package = new ExePackage(@"..\redist\NDP40-KB2468871-v2-x64.exe") { Description = "This prerequisite installs the .NET Framework 4.0 full profile update provided in Microsoft KB article 2468871.", Compressed = false, DownloadUrl = "http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/NDP40-KB2468871-v2-x64.exe", Name = "NDP40-KB2468871-v2-x64.exe", //SourceFile = "NDP40-KB2468871-v2-x64.exe", Vital = true, PerMachine = true, Permanent = true, //ExitCodes = new List<ExitCode>() { new ExitCode(){Value = "1641",Behavior = BehaviorValues.scheduleReboot}, new ExitCode() { Value = "3010", Behavior = BehaviorValues.scheduleReboot } }, InstallCommand = "/q /norestart", DetectCondition = $"({variableNameForX64}) OR (VersionNT64 >= v6.0)", InstallCondition = $"(VersionNT64 < v6.0) AND (NOT {variableNameForX64})", }; _kb2468871X86Package = new ExePackage(@"..\redist\NDP40-KB2468871-v2-x86.exe") { Description = "This prerequisite installs the .NET Framework 4.0 full profile update provided in Microsoft KB article 2468871.", Compressed = false, DownloadUrl = "http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/NDP40-KB2468871-v2-x86.exe", Name = "NDP40-KB2468871-v2-x86.exe", //SourceFile = "NDP40-KB2468871-v2-x86.exe", Vital = true, PerMachine = true, Permanent = true, //ExitCodes = new List<ExitCode>() { new ExitCode(){Value = "1641",Behavior = BehaviorValues.scheduleReboot}, new ExitCode() { Value = "3010", Behavior = BehaviorValues.scheduleReboot } }, InstallCommand = "/q /norestart", DetectCondition = $"({variableNameForX86}) OR (VersionNT >= v6.0)", InstallCondition = $"(VersionNT < v6.0) AND (NOT {variableNameForX86}) AND (NOT VersionNT64)", }; return(new[] { _kb2468871X64Package, _kb2468871X86Package, }); }
static void Main(string[] args) { var productProj = new ManagedProject("My Product", new Dir("[INSTALLDIR]", new Dir("bin", new File("ui.config")), new Dir("obj", new File("ui.config")) ), new RegValue(RegistryHive.LocalMachine, @"SOFTWARE\My Product", "test", "testvalue"), new RemoveRegistryKey(RegistryHive.LocalMachine, @"Software\My Product")) { InstallPrivileges = InstallPrivileges.elevated, InstallScope = InstallScope.perMachine, GUID = new Guid("6a330b47-2577-43ad-9095-1861bb25889a") }; //productProj.Load += (SetupEventArgs e) => { // e.Session.Property("INSTALLDIR"); //}; string productMsi = productProj.BuildMsi(); //------------------------------------ var bootstrapper = new Bundle("TestInstall", new PackageGroupRef("NetFx47Redist"), new MsiPackage(productMsi) { Id = "TestInstall", DisplayInternalUI = false, MsiProperties = @"USERINPUT=[UserInput];INSTALLDIR=[InstallPath]" }); bootstrapper.WxsFiles.Add("Net47.wxs"); bootstrapper.Include(WixExtension.Util); //bootstrapper.Include(WixExtension.NetFx); bootstrapper.AddXmlElement("Wix/Bundle", "Log", "PathVariable=LogFileLocation"); bootstrapper.Variables = new[] { new Variable("LogFileLocation", $"D:\\log.txt") { Overridable = true }, new Variable("UserInput", "<none>"), new Variable("InstallPath", "[ProgramFiles6432Folder]\\My Company\\My Product"), }; bootstrapper.AddWixFragment("Wix/Bundle", new UtilRegistrySearch { Root = RegistryHive.LocalMachine, Key = @"SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full", Value = "Version", Variable = "Netfx4FullVersion", Result = SearchResult.value }); bootstrapper.Version = new Version("1.0.0.0"); bootstrapper.UpgradeCode = new Guid("6a330b47-2577-43ad-9095-1861bb25889a"); bootstrapper.IconFile = @"Res\test.ico"; // You can also use System.Reflection.Assembly.GetExecutingAssembly().Location instead of "%this%" // Note, passing BootstrapperCore.config is optional and if not provided the default BootstrapperCore.config // will be used. The content of the default BootstrapperCore.config can be accessed via // ManagedBootstrapperApplication.DefaultBootstrapperCoreConfigContent. // // Note that the DefaultBootstrapperCoreConfigContent may not be suitable for all build and runtime scenarios. // In such cases you may need to use custom BootstrapperCore.config as demonstrated below. bootstrapper.Application = new ManagedBootstrapperApplication(typeof(App).Assembly.Location); ManagedBootstrapperApplication.DefaultBootstrapperCoreConfigContent = @"<?xml version=""1.0"" encoding=""utf-8"" ?><configuration><configSections><sectionGroup name=""wix.bootstrapper"" type=""Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore""><section name=""host"" type=""Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore"" /></sectionGroup></configSections><startup useLegacyV2RuntimeActivationPolicy=""true""><supportedRuntime version=""v4.0"" /></startup><wix.bootstrapper><host assemblyName=""WixBootstrapperWPF""> <supportedFramework version=""v4\Full"" /><supportedFramework version=""v4\Client"" /></host></wix.bootstrapper></configuration>"; //var asse = ass.GetExecutingAssembly(); //var names = asse.GetManifestResourceNames(); //using (io.StreamReader reader = new io.StreamReader(asse.GetManifestResourceStream("ui.config"))) { // ManagedBootstrapperApplication.DefaultBootstrapperCoreConfigContent = reader.ReadToEnd(); //} bootstrapper.PreserveTempFiles = true; bootstrapper.SuppressWixMbaPrereqVars = true; bootstrapper.Build("my_app.exe"); }