开发者

Issues regarding Installing an Application via Windows Installer

I have an Windows Installer for my application. Application package also contains Installer class where some of the actions are performed other are performed in Custom Actions.

The Installer installs another application from Custom Actions during Install. I want to know if this application already exists of same version I don't want to install or provide a Messagebox asknig to Reinstall Y/N.

If my application is already installed, and I click the same installer again, I get "Repair" and "Remove" options. But if the installer is newly built, I get a dialog stating "Another version is already installed ... remove using Add Remove Programs..". So I can't update the exisitng version without uninstallng it. How can I update the existing version ?

Any help or guidance for these 2 queries are highly appreciated. I looked on net for these but couldn't get apropriae answers. If you can help me, that would be really great.

CODE

prouct.xml

<?xml version="1.0" encoding="utf-8" ?>
<Product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
 ProductCode="My.Bootstrapper.ABC">

 <!-- Create Package, Product Manifest http://msdn.microsoft.com/en-us/library/ee335702.aspx
  Schema Reference : http://msdn.microsoft.com/en-us/library/ms229223.aspx
   -->

 <PackageFiles>
     <PackageFile Name="XYZ.exe"/>
 </PackageFiles>

 <InstallChecks>
     <!-- If its installed, it will be in Uninstall. DisplayName will be XYZ2.1_rc22  
     Can still get values of DisplayVersion (2.1_rc22) & UninstallString from this key
     -->
    <RegistryCheck
       Property="IS_XYZ_INSTALLED"
       Key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\XYZ"
       Value="DisplayName"/>
  </InstallChecks>

  <Commands>
     <Command PackageFile="XYZ.exe" Arguments="/Install">
     <Insta开发者_如何学JAVAllConditions>
         <BypassIf Property="IS_XYZ_INSTALLED" 
           Compare="ValueEqualTo" Value="XYZ2.1_rc22"/>    // tHIS IS THE DISPLAYNAME, THAT I SEE IN REGISTY
        <FailIf Property="AdminUser"
           Compare="ValueNotEqualTo" Value="True"
           String="NotAnAdmin"/>
     </InstallConditions>

     <ExitCodes>
       <ExitCode Value="0" Result="Success"/>
       <ExitCode Value="1641" Result="SuccessReboot"/>
       <ExitCode Value="3010" Result="SuccessReboot"/>
       <DefaultExitCode Result="Fail" String="GeneralFailure"/>
     </ExitCodes>
   </Command>
 </Commands>

</Product>

package.xml

<?xml version="1.0" encoding="utf-8" ?>
<Package  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
    Name="DisplayName" Culture="Culture">

 <!--Check for XYZversion 2.1_rc22 -->
 <Strings>
    <String Name="DisplayName">Install My XYZ</String>
    <String Name="Culture">en</String>
   <String Name="NotAnAdmin">Administrator permissions are required to install XYZ.Contact your 
              administrator.</String>
   <String Name="GeneralFailure">A general error has occurred while installing this   
          package.</String>
  </Strings>
</Package>

UPDATE : I want to install XYZ if it is not alerady installed on PC. With the Above code it doesn't install as Prerequisite. In Prerequisite I select my appication (along with Windows Installer 3.1 & .NET3.5) and have selected "Download prereq from same location as my appli". On Build of setup project, I get 3 folders in my Rel (for winIns, Net & my app o be installed as preq i.e. XYZ). Currently XYZ is not installed on my comp - so the key will not be found. When I install the installer, it installs the app but not the prereq i.e XYZ.exe application. Where am I going wrong ?

Thanks .


The Installer installs another application from Custom Actions during Install. I want to know if this application already exists of same version I don't want to install or provide a Messagebox asknig to Reinstall Y/N.

Instead of a custom action you should use a prerequisite. If you are using a Visual Studio setup project, perhaps this will help: Adding Custom prerequsites to visual studio setup project

If you are using another setup authoring tool, you should find out if it supports prerequisites or not.

If my application is already installed, and I click the same installer again, I get "Repair" and "Remove" options. But if the installer is newly built, I get a dialog stating "Another version is already installed ... remove using Add Remove Programs..". So I can't update the exisitng version without uninstallng it. How can I update the existing version ?

This happens because you modified the package without increasing the ProductVersion and modifying the ProductCode. If you want an automatic upgrade you need to modify them.

However, if you are just testing and you don't want to increase the ProductVersion, you need to manually uninstall the old package before installing the new one. This is how Windows Installer upgrades work.


  1. You can check the version of the executable files using GetFileVersionInfo and VerQueryValue WinAPI functions (there must be .Net counterparts).

  2. You can change ProductCode each time you generate MSI package. Upgrades must include the current version, i.e. you need to allow upgrades between the same version of the package, without changing the ProductVersion.

    Yet I would recommend following Cosmin's recommendation.


Update: answering to comment.

<Upgrade Id="Your-Upgrade-GUID">
  <UpgradeVersion Minimum="$(var.ProductVersion)"
                  IncludeMinimum="no"
                  OnlyDetect="yes"
                  Language="1033"
                  Property="NEWPRODUCTFOUND" />
  <!-- NEWPRODUCTFOUND property is set if a newer product version
       is installed. It is used to prevent downgrades. -->

  <UpgradeVersion Minimum="1.0.0"
                  IncludeMinimum="yes"
                  Maximum="$(var.ProductVersion)"
                  IncludeMaximum="yes"
                  Language="1033"
                  Property="UPGRADEFOUND" />
  <!-- UPGRADEFOUND property is set if older product version is installed
       or the same as the value of ProductVersion variable -->
</Upgrade>

We use the code above to perform upgrades even between the same version of the application. ProductVersion is a WiX preprocessor variable that contains the current version of the product. PackageCode is auto generated each build, using * as its value in .wsx file.

The key to make it work is IncludeMaximum="yes" attribute in the second UpgradeVersion element and the fact that each generated package has unique PackageCode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜