2014-01-28 63 views
0

我已经创建了一个Wix安装程序,用于替换在Visual Studio中创建的安装程序,并且应该更新它正在安装的软件的先前版本。我一直认为是在以前版本的安装矿用同样的升级代码,所以我认为这个代码将工作:Wix 3.8:安装程序不卸载以前的版本或安装新版本

<?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

+0

嗯,我想我发现了为什么服务不会启动。不知何故,主dll依赖的我的一个程序集在安装后被重命名。这解决了这个错误。一旦我解决了问题,我们会看看是否还有其他问题。 – Neverforget115

回答

相关问题