1
votes

I have created a silent installer Using WIX for my application. I want it to install my application to C:\MyApps folder but its Directory Id='TARGETDIR' Name='SourceDir' tag randomly picks C or D drive. I want to enforce my installation to C drive only. Also in case, I provide version number greater than 4.0.5, I am geting an error during installation saying "This installation package cannot be installed by the Windows Installer Service. You must install a newer version of the Window Installer service." I am having Windows XP professional SP3 Version 2002.

4
Can you please pot the code that defines your product version. It sounds to me like you're defining the Windows Installer version instead of your product's version.Hand-E-Food
My product & package tags look like <Product Name="My Application Name" Id="*" UpgradeCode="FIXED GUID HERE" Language="1033" Version="4.0.6" Manufacturer="ABC"> <Package Id="*" InstallerVersion="406" Compressed="yes" Description="Installer Number 406" />................Singla Amit

4 Answers

4
votes

To begin with, I think you should start your WiX journey with the tutorial available here. It contains the answers to the most of basic questions you'll face with the first thing. You should also be aware that understanding WiX means understanding the concepts of Windows Installer first - otherwise some points will seem a weird magic to you.

When you create a new WiX setup project in Visual Studio, it generates a template with some placeholders. It is recommended to start modifying this template. For instance, the directory structure:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLLOCATION" Name="SetupProject1">
      <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
      <!-- <Component Id="ProductComponent" Guid="ba7d579f-5234-4448-b880-109f589d58e5"> -->
      <!-- TODO: Insert files, registry keys, and other resources here. -->
      <!-- </Component> -->
    </Directory>
  </Directory>
</Directory>

This snippet defines the INSTALLLOCATION folder under the ProgramFileFolder, and this is a better approach than to place it under the C:\ root. You can still change the installation location by modifying the INSTALLLOCATION property at install time (for instance, base on user's input).

The quick answer to your questions are:

...randomly picks C or D drive...

That's expected - it picks the drive with the most free space by the time of installation. If you stick to the way WiX template defines by default, it will fall under C: (actually, under Program Files folder).

...You must install a newer version of the Window Installer service...

Basically, it means what it says - the version Windows Installer on your machine is lower than the one you require in your package. If you try to solve the above problems with this change, then it has nothing to do with the Windows Installer version. You should require higher version than it is specified by default only in case you are going to use new features of Windows Installer.

Hope you'll make right conclusion out of this brief intro - start with the tutorial. :-)

2
votes

The problem with your versions is you're changing the Windows Installer version when you change your Product version.

<Package
    Id='*' 
    InstallerVersion='406'
    Compressed='yes'
    Description="Installer Number 406" />

The InstallerVersion attribute should be the minimum required version of Windows Installer required to install this package. You have Windows Installer v4.5 installed. When this is set to 406, it looks for Windows Installer v4.6 which frankly, doesn't exist. Setting this to 301 (version 3.1) is usually sufficient.

    InstallerVersion='301'

While your description attribute is fine, I would find the following more meaningful:

    Description="My Product v4.0.6 Installer"
2
votes

Try this:

<Fragment>
    <Property Id="_BrowseProperty" Value="INSTALLDIR" Secure="yes"/>
    <CustomAction Id="SetDataLocationDefault" Property="INSTALLDIR" Value="[WindowsVolume]$(var.Title)\" />
    <InstallUISequence>
      <Custom Action="SetDataLocationDefault" After="CostFinalize" />
    </InstallUISequence>
    <InstallExecuteSequence>
      <Custom Action="SetDataLocationDefault" After="CostFinalize" />
    </InstallExecuteSequence>    
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="INSTALLDIR" Name="$(var.Title)">
     <!-- TODO: Insert your components here. -->
      </Directory>
    </Directory>

  </Fragment>

I think this should work!

0
votes

Do not rely on TARGETDIR, and use the custom property, like this:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLLOCATION" Name="SetupProject1">
      <!-- TODO: Insert your components here. -->
  </Directory>
</Directory>

The template is taken from Yan's answer. Set INSTALLLOCATION to the desired folder C:\MyApps, that should do the trick.