static public void Main() { var setup = new NativeBootstrapper(); setup.PrerequisiteFile = @"C:\Users\Admin\Downloads\dotnetfx.exe"; setup.PrimaryFile = "MainProduct.msi"; setup.OutputFile = "dotnet_setup.exe"; setup.PrerequisiteRegKeyValue = @"HKLM:SOFTWARE\Microsoft\.NETFramework:InstallRoot"; //note reg key value InstallRoot will exist if "any .NET version installed" setup.Build(); }
/// <summary> /// Builds the bootstrapper. /// </summary> /// <param name="prerequisiteFile">The prerequisite file.</param> /// <param name="primaryFile">The primary setup file.</param> /// <param name="outputFile">The output (bootsrtapper) file.</param> /// <param name="prerequisiteRegKeyValue">The prerequisite registry key value. /// <para>This value is used to determine if the <c>PrerequisiteFile</c> should be launched.</para> /// <para>This value must comply with the following pattern: <RegistryHive>:<KeyPath>:<ValueName>.</para> /// <code>PrerequisiteRegKeyValue = @"HKLM:Software\My Company\My Product:Installed";</code> /// Existence of the specified registry value at runtime is interpreted as an indication of the <c>PrerequisiteFile</c> has been alreday installed. /// Thus bootstrapper will execute <c>PrimaryFile</c> without launching <c>PrerequisiteFile</c> first.</param> /// <param name="doNotPostVerifyPrerequisite">The flag which allows you to disable verification of <c>PrerequisiteRegKeyValue</c> after the prerequisite setup is completed. /// <para>Normally if <c>bootstrapper</c> checks if <c>PrerequisiteRegKeyValue</c>/> exists straight after the prerequisite installation and starts /// the primary setup only if it does.</para> /// <para>It is possible to instruct bootstrapper to continue with the primary setup regardless of the prerequisite installation outcome. This can be done /// by setting DoNotPostVerifyPrerequisite to <c>true</c> (default is <c>false</c>)</para> ///</param> /// <param name="optionalArguments">The optional arguments for the bootstrapper compiler.</param> /// <returns>Path to the built bootstrapper file. Returns <c>null</c> if bootstrapper cannot be built.</returns> /// /// <example>The following is an example of building bootstrapper <c>Setup.msi</c> for deploying .NET along with the <c>MyProduct.msi</c> file. /// <code> /// WixSharp.CommonTasks.Tasks.BuildBootstrapper( /// @"C:\downloads\dotnetfx.exe", /// "MainProduct.msi", /// "setup.exe", /// @"HKLM:Software\My Company\My Product:Installed" /// false, /// ""); /// </code> /// </example> static public string BuildBootstrapper(string prerequisiteFile, string primaryFile, string outputFile, string prerequisiteRegKeyValue, bool doNotPostVerifyPrerequisite, string optionalArguments) { var nbs = new NativeBootstrapper { PrerequisiteFile = prerequisiteFile, PrimaryFile = primaryFile, OutputFile = outputFile, PrerequisiteRegKeyValue = prerequisiteRegKeyValue }; nbs.DoNotPostVerifyPrerequisite = doNotPostVerifyPrerequisite; if (!optionalArguments.IsEmpty()) { nbs.OptionalArguments = optionalArguments; } return(nbs.Build()); }
/// <summary> /// Builds the bootstrapper. /// </summary> /// <param name="prerequisiteFile">The prerequisite file.</param> /// <param name="primaryFile">The primary setup file.</param> /// <param name="outputFile">The output (bootsrtapper) file.</param> /// <param name="prerequisiteRegKeyValue">The prerequisite registry key value. /// <para>This value is used to determine if the <c>PrerequisiteFile</c> should be launched.</para> /// <para>This value must comply with the following pattern: <RegistryHive>:<KeyPath>:<ValueName>.</para> /// <code>PrerequisiteRegKeyValue = @"HKLM:Software\My Company\My Product:Installed";</code> /// Existence of the specified registry value at runtime is interpreted as an indication of the <c>PrerequisiteFile</c> has been alreday installed. /// Thus bootstrapper will execute <c>PrimaryFile</c> without launching <c>PrerequisiteFile</c> first.</param> /// <param name="doNotPostVerifyPrerequisite">The flag which allows you to disable verification of <c>PrerequisiteRegKeyValue</c> after the prerequisite setup is completed. /// <para>Normally if <c>bootstrapper</c> checks if <c>PrerequisiteRegKeyValue</c>/> exists straight after the prerequisite installation and starts /// the primary setup only if it does.</para> /// <para>It is possible to instruct bootstrapper to continue with the primary setup regardless of the prerequisite installation outcome. This can be done /// by setting DoNotPostVerifyPrerequisite to <c>true</c> (default is <c>false</c>)</para> ///</param> /// <param name="optionalArguments">The optional arguments for the bootstrapper compiler.</param> /// <returns>Path to the built bootstrapper file. Returns <c>null</c> if bootstrapper cannot be built.</returns> /// /// <example>The following is an example of building bootstrapper <c>Setup.msi</c> for deploying .NET along with the <c>MyProduct.msi</c> file. /// <code> /// WixSharp.CommonTasks.Tasks.BuildBootstrapper( /// @"C:\downloads\dotnetfx.exe", /// "MainProduct.msi", /// "setup.exe", /// @"HKLM:Software\My Company\My Product:Installed" /// false, /// ""); /// </code> /// </example> static public string BuildBootstrapper(string prerequisiteFile, string primaryFile, string outputFile, string prerequisiteRegKeyValue, bool doNotPostVerifyPrerequisite, string optionalArguments) { var nbs = new NativeBootstrapper { PrerequisiteFile = prerequisiteFile, PrimaryFile = primaryFile, OutputFile = outputFile, PrerequisiteRegKeyValue = prerequisiteRegKeyValue }; nbs.DoNotPostVerifyPrerequisite = doNotPostVerifyPrerequisite; if (!optionalArguments.IsEmpty()) nbs.OptionalArguments = optionalArguments; return nbs.Build(); }