How to include prerequisites with msi/Setup.exe in WIX
Asked Answered
B

4

4

I'm trying to combine my package in a single setup EXE file and upload it to the Internet.

I have created a Microsoft bootstrapper that contains Setup.exe with project MSI output, and pre-requisite .NET Framework 2.0, Windows Installer 3.1 , Visual C++ 2005 redistributables, and Microsoft ReportViewer. I have created a setup project using Visual Studio 2008.

Now I'm trying to create a single compressed setup using WiX 3.6. I have installed it in Visual Studio 2008.

I have attached the setup.exe and MSI file using following commands.

<ExePackage SourceFile ="setup.exe" Compressed ="yes"/>
<MsiPackage SourceFile ="myproject.msi" Compressed ="yes" />

But it is unable to find the MSI file. How can I include the above prerequisites with it?

Or can I download the above prerequisites from the Internet while installing? How do I do it?

Balcke answered 4/7, 2013 at 12:11 Comment(0)
B
7

I have removed the default setup.exe from Visual Studio and used the MSI file and dependencies from Visual Studio to create a WiX 3.6 Bootstrapper:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <Bundle Name="My Application"
            Version="1.0"
            IconSourceFile ="E:\logo.ico"
            Manufacturer="My company"
            UpgradeCode="4dcab09d-baba-4837-a913-1206e4c2e743">

        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
            <bal:WixStandardBootstrapperApplication
                LicenseFile="E:\License.rtf"
                SuppressOptionsUI ="yes"
                LogoFile ="logo.ico" />
        </BootstrapperApplicationRef>

        <Chain>
            <ExePackage
                SourceFile ="ReportViewer\ReportViewer.exe"
                Compressed ="yes"
                Vital ="no"
                Permanent ="yes"/>
            <ExePackage
                SourceFile ="vcredist_x86\vcredist_x86.exe"
                Compressed ="yes"
                Vital ="no"
                Permanent ="yes"/>
            <MsiPackage
                SourceFile ="MySetup.msi"
                Compressed ="yes"
                DisplayName ="My Application"
                ForcePerMachine ="yes"/>
        </Chain>
    </Bundle>
</Wix>

It compresses into an single EXE file with prerequisites.

Balcke answered 16/8, 2013 at 14:28 Comment(0)
S
5

SourceFile will accept a relative path the .msi file. Or, if you are building the .msi file with a WiX Setup project, you can add a reference to the Setup project in the WiX Bootstrapper project. That defines variables you can use like this:

<MsiPackage SourceFile ="$(var.myproject.TargetPath)" Compressed ="yes" />

Your users will probably have a better experience if you drop the Visual Studio Bootstrapper and put all prerequisites in the WiX Bootstrapper. It'll be a little more work for you because there isn't a pre-defined ExePackageGroup or ExePackage for all of your project's prerequisites.

The best place to check for information on what should go into an ExePackage definition is the documentation for the particular prerequisite in question. But, it is also instructive to compare with the Visual Studio Bootstrapper packages (in, e.g., C:\Program Files\Microsoft Visual Studio 9\SDK\v2.0\Bootstrapper\Packages) and similar prerequisites that might be predefined in the WiX source code. In particular, in the WiX source code, you will find an ExePackage that downloads .NET 4 from the Internet if needed while installing.

Samarasamarang answered 5/7, 2013 at 2:9 Comment(0)
H
2

You can include some pre-requisite file with something like:

 <?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
 <Product Id="*" Name="MyApplication" Version="$(var.ProductVersion)" Manufacturer="manuf" Language="1033">

 [...]

 <Directory Id="ANOTHERLOCATION" Name="MyApplicationName">
    <Component Id="ApplicationFiles" Guid="12345678-1234-1234-1235-111111111111">
         <File Id="ApplicationFile4" Source="C:\Users\user\Desktop\requisite.exe"/>
         <CreateFolder />
    </Component>
 </Directory>
 <SetDirectory Id="ANOTHERLOCATION" Value="[WindowsVolume]MyApp" />
         <Feature Id="DefaultFeature" Level="1">
        <ComponentRef Id="ApplicationFiles" />
 </Feature>
 </Product>
 </Wix>

The above copies the requisite.exe file inside C:/MyApp. You then have to run the requisite.exe file from your program based on some conditions. This is the most basic and straight-forward way without using complicated Wix wizardry.

Hookah answered 4/7, 2013 at 12:32 Comment(3)
if i need to check for pre-requisite whether it is previously installed or not ? If not then install otherwise skip the installation.. How to check this condition ?Balcke
My suggestion is to insert the pre-requisite check and possible installation inside your program (if it can first run without this prerequisite). You could for instance store this information inside an .ini file and read it with your program, if not found then call a System.Diagnostics.Process.Start("requisite.exe"); to launch itHookah
That would require re-elevation to admin for the installation of prerequisites. Fine for you and me, but not acceptable when installing custom software in a tightly managed domain like an industrial plant.Heyman
K
0

You can use something like NSIS to wrap up your bootstrapper and MSI. You'll need to write a simple NSIS script, like this:

!define PRODUCT_NAME "YourProductNameHere"

Name "${PRODUCT_NAME}"
OutFile "SetupWrapper.exe"
Icon "Setup.ico"
BrandingText " "
SilentInstall silent

Section

  SetOutPath "$TEMP\${PRODUCT_NAME}"

  ; Add all files that your installer needs here
  File "setup.exe"
  File "product.msi"

  ExecWait "$TEMP\${PRODUCT_NAME}\setup.exe"
  RMDir /r /REBOOTOK "$TEMP\${PRODUCT_NAME}"

SectionEnd

Save this to a file named SetupWrapper.nsi, and edit the product name and paths to setup.exe and your MSI file. Now you can build this file to get a single EXE file that contains the bootstrapper and the MSI.

When this EXE is run, it will not have any UI of its own -- it will simply extract your bootstrapper and MSI to a temp folder, then execute the bootstrapper, and clean up afterwards.

You can also add a post-build step to your project to build this wrapper, which will automatically generate the combined wrapper EXE. To do this, you can add a command like this:

path-to-NSIS\nsis-2.46\makensis.exe /V2 your-project-path\SetupWrapper.nsi
Kilmarnock answered 12/8, 2013 at 10:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.