Wix 3.8:安装程序未卸载以前的版本或安装新版本

时间:2014-01-28 14:40:43

标签: windows-services wix

我创建了一个Wix安装程序,用于替换在Visual Studio中创建的安装程序,并且应该更新它正在安装的软件的先前版本。我保留了以前安装程序中使用的相同升级代码,因此我认为此代码可以正常工作:

    <?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="*"
         Name="Product"
         Language="1033"
         Version="1.0.6.0"
         Manufacturer="Company"
         UpgradeCode="PREVIOUSLY-USED-UPGRADE-CODE">
    <Package InstallerVersion="301"
             Compressed="yes"
             InstallScope="perMachine"
             Manufacturer="Company"
             Description="Installs Product"
             Keywords="Installer,MSI" />
    <Media Id="1"
           Cabinet = "Product.cab"
           EmbedCab = "yes"/>

    <MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of Product is already installed." AllowDowngrades="no"/>

    <Directory Id ="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="CompanyFolder" Name ="Company">
          <Directory Id="INSTALLDIR" Name="Product" />
        </Directory>
      </Directory>
    </Directory>

    <Feature Id ="ProductFeature"
             Title = "Product Feature"
             Level = "1">
      <ComponentGroupRef Id="ProductComponents"/>
    </Feature>

    <ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">

      <Component Id="cmpCOMAdminW2K" Guid="*">
        <File Id="COMAdminW2K" Vital="yes" KeyPath="yes" Name="Interop.COMAdminW2K.dll" Source="Local\Path\To\Interop.COMAdminW2K.dll" />

      <!-- Several registry entry updates -->
      </Component>

      <Component Id="cmpCustomSerializer" Guid="*">
        <File Id="CustomSerializer" Vital="yes" KeyPath="yes" Name="AREANAME.Serialization.CustomSerializer.v2.0.dll" Source="Local\Path\To\AREANAME.Serialization.CustomSerializer.v2.0.dll" />
      </Component>

      <Component Id="cmpProductServer" Guid="*">
        <File Id="ProductServer" Vital="yes" KeyPath="yes" Name="AREANAME.ProductServer.Shared.v2.0.dll" Source="Local\Path\To\AREANAME.ProductServer.Shared.v2.0.dll" />
      </Component>

      <Component Id="cmpRemotingHelper" Guid="*">
        <File Id="RemotingHelper" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.RemotingHelper.v2.0.dll" Source="Local\Path\To\ND1.TechPC.RemotingHelper.v2.0.dll" />
      </Component>

      <Component Id="cmpProduct" Guid="*">
        <File Id="Product" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.Service.Product.v2.0.exe" Source="Local\Path\To\AREANAME.TechPC.Service.Product.v2.0.exe" />
        <ServiceInstall
          Id="Product"
          Name="ServiceName"
          DisplayName="Full Service Name"
          Start="auto"
          ErrorControl="normal"
          Type="ownProcess"/>

        <ServiceControl
          Id="startAndStopUsrPres"
          Name="ServiceName"
          Start="install"
          Stop="both"
          Remove="uninstall"
          Wait="yes"/>
      </Component>

      <Component Id="cmpProductConfig" Guid="*">
        <File Id="ProductConfig" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.Service.Product.v2.0.exe.config" Source="Local\Path\To\AREANAME.TechPC.Service.Product.v2.0.exe.config" />
        <RemoveFile Id="RemoveProductConfig" Name="AREANAME.TechPC.Service.Product.v2.0.exe.config" On ="install"/>
      </Component>

      <Component Id="VersionRegistryEntry" Guid="*">
        <RegistryKey Root="HKLM"
                     Key="Software">

          <RegistryKey Key="Company"
                       ForceCreateOnInstall="yes">

            <RegistryKey Key="Product"
                         ForceCreateOnInstall="yes">

              <RegistryValue Id="ProductVersionEntry"
               KeyPath ="yes"
               Action ="write"
               Name="Version"
               Value="1.0.6.0"
               Type="string"/>

            </RegistryKey>
          </RegistryKey>
        </RegistryKey>

      </Component>
    </ComponentGroup>
  </Product>
</Wix>

*上面的代码显然是编辑过的。

安装程序将通过软件管理系统在我公司的几乎所有机器上运行,因此我一直在使用以下命令行测试我的安装程序:

msiexec.exe /i <ProductInstaller>.msi /quiet /l*v log.txt

这让我想到问题。有些人可能已经注意到我在包含配置文件的组件中有一个“RemoveFile”标记。我有它,因为安装程序运行时该文件并不总是更新。这与MajorUpgrade计划相结合,允许我从目标目录中删除该文件,并确保新的配置文件始终放在该位置。这个修复似乎在我的测试中起作用。每当我尝试在具有该程序的先前版本的计算机上运行安装程序时,程序文件似乎都是正确的。但是,即使所有正确的文件都在正确的位置,服务也不会自动启动,也不会通过手动尝试在services.msc中启动它来启动。此外,每当我尝试运行以下内容进行卸载时:

msiexec.exe /x <ProductInstaller>.msi /quiet /l*v log.txt

我收到错误消息“此操作仅适用于当前安装的产品。”

我不知道该怎么做,因为新文件应该是它们的位置,旧文件已经消失。

有了所有这些信息,我的问题有些模糊:“我有什么缺失,以便安装程序将所有文件放在正确的位置并在安装时启动服务,并停止服务并删除卸载时的文件?“

任何帮助都会受到赞赏,我很乐意根据要求向任何认为可以帮助我弄清楚发生了什么的人提供部分日志文件。

谢谢! -Seth

1 个答案:

答案 0 :(得分:0)

事实上,重命名.dll会导致问题。

相关问题