1

我从 VS2010 升级到 VS2012。我有一个带有设置的客户端应用程序。我使用 Windows-Installer 来创建设置。现在我想升级我的项目并遇到VS2012不再支持Windows-Installer的问题。我尝试使用 WIX 创建一个新设置。这是我的新设置文件:

<?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="FADB7F3E-0E92-494E-B627-930BC217DE29" Name="SMC" Language="1033" Version="1.1.1"
       Manufacturer="abc" UpgradeCode="1BC520F0-F6CB-4E70-8F7B-9F398BE4F25B">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<!--<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />-->
<MediaTemplate />


<Upgrade Id="1BC520F0-F6CB-4E70-8F7B-9F398BE4F25B">
  <!--<UpgradeVersion Minimum="1.1.1.0" IncludeMinimum="no" OnlyDetect="no" Property="NEWERVERSIONDETECTED" />-->
  <UpgradeVersion Minimum="0.0.0.0" Maximum="1.1.1.0" IncludeMinimum="yes" IncludeMaximum="yes" Property="OLDERVERSIONBEINGUPGRADED" />
</Upgrade>

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallFinalize" />
  <Custom Action="NewerVersion" After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom>
</InstallExecuteSequence>

<CustomAction Id="NewerVersion" Error="A later version of [ProductName] is already installed." />


<!--<Fragment>-->
<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="abc">
      <Directory Id="PROGFOLDER" Name="SMC">
        <Directory Id="IMAGES" Name="images"/>
        <Directory Id="CULTURE" Name="de-DE" />
      </Directory>
    </Directory>
    <Directory Id="ProgramMenuFolder">
      <Directory Id="SMC_Shortcut" Name="abc">
      </Directory>
    </Directory>
  </Directory>
</Directory>
<!--</Fragment>-->

<!--<Fragment>-->
<DirectoryRef Id="IMAGES">
  <Component Id="Image" Guid="82BB42E8-AD7A-4E62-B5B7-37C7EA2DFC8D">
    <File Id="Program_Icon" Source="C:\Projects\SMC\Dev\SMC\images\SMC.ico" KeyPath="yes" Checksum="yes" />
  </Component>
</DirectoryRef>
<DirectoryRef Id="CULTURE">
  <Component Id="Lang" Guid="109183AC-3F37-4BDC-B659-38C12CE4BAD3">
    <File Id="Language" Source="C:\Projects\SMC\Dev\Culture\bin\Release\de-DE\Culture.resources.dll" KeyPath="yes" Checksum="yes" />
  </Component>
</DirectoryRef>
<DirectoryRef Id="PROGFOLDER">
  <Component Id="Dll_Culture" Guid="AC8103CF-FDFB-4792-BF84-577F27A3CC1B">
    <File Id="culture_dll" Source="C:\Projects\SMC\Dev\Culture\bin\Release\Culture.dll" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Dll_Helper" Guid="33DEC912-AF34-4473-8E6D-E36D07B644B1">
    <File Id="helper_dll" Source="C:\Projects\SMC\Dev\Helper\bin\Release\Helper.dll" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Dll_Secman" Guid="9E543EF7-5205-49F2-9B2A-52D0D469781D">
    <File Id="secman_dll" Source="C:\Projects\SMC\Tools\secman.dll" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Dll_SecurityManager" Guid="AF80A4B2-3B5F-4CA9-B357-65AC9031CFF3">
    <File Id="securityManager_2005_dll" Source="C:\Projects\SMC\Tools\SecurityManager.2005.dll" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Dll_UDDI" Guid="35EFC304-EB62-4EB4-A1F4-4D0E0AE56A76">
    <File Id="uddiConnect_dll" Source="C:\Projects\SMC\Tools\abc.UddiConnectLib.dll" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Exe_SMC" Guid="48FF7F56-D4E1-4CE6-B333-8F8BF73B6D58">
    <File Id="exe_file" Source="C:\Projects\SMC\Dev\SMC\bin\Release\SMC.exe" KeyPath="yes" Checksum="yes" />
  </Component>
  <Component Id="Exe_SMC.config" Guid="865139C6-740A-499B-8C0E-FAF163A4A98F">
    <File Id="exe_file.config" Source="C:\Projects\SMC\Dev\SMC\bin\Release\SMC.exe.config" KeyPath="yes" Checksum="yes" />
  </Component>
</DirectoryRef>
<DirectoryRef Id="SMC_Shortcut">
  <Component Id="shortcut" Guid="46E8006D-9A0A-4086-94AE-A002F6C5B4D7">
    <Shortcut Id="SMC_abc" Name="SMC" Description="SMC"
              Target="[PROGFOLDER]SMC.exe" Icon="SMC_Icon" Arguments="prod">
      <Icon Id="SMC_Icon" SourceFile="C:\Projects\SMC\Dev\SMC\images\SMC.ico" />
    </Shortcut>
    <RegistryValue Root="HKMU" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="SMC"
                   Type="string" Value="[PROGFOLDER]SMC.exe prod" KeyPath="yes" />
    <RemoveFile Id="SMC_abc" Name="SMC" On="uninstall" />
  </Component>
</DirectoryRef>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <ComponentRef Id="Image" />
  <ComponentRef Id="Lang" />
  <ComponentRef Id="Dll_Culture" />
  <ComponentRef Id="Dll_Helper" />
  <ComponentRef Id="Dll_Secman" />
  <ComponentRef Id="Dll_SecurityManager" />
  <ComponentRef Id="Dll_UDDI" />
  <ComponentRef Id="Exe_SMC" />
  <ComponentRef Id="Exe_SMC.config" />
  <ComponentRef Id="shortcut" />
</ComponentGroup>

<!--</Fragment>-->

<Feature Id="ProductFeature" Title="SMC.SetupTest" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
</Feature>
<Property Id="ARPPRODUCTICON">RemoveIcon</Property>
<Icon Id="RemoveIcon" SourceFile="C:\Projects\SMC\Dev\SMC\images\SMC.ico" />


<CustomAction Id="OurAction" FileKey="exe_file" ExeCommand="prod" Execute="immediate" Return="asyncNoWait" />

它会安装新版本,但不会卸载旧版本。旧程序仍然出现在控制面板的程序和功能中。我怎样才能删除这个版本。

我尝试使用两个版本的 Wix-Setup 进行安装。当我尝试安装较新版本时,它会显示一个带有以下消息的消息框:安装了此软件的另一个版本...

有人能帮我吗?

4

1 回答 1

1

你可以做到这一点是几个步骤:

  1. 使用 Orca 打开您拥有的旧 MSI。
  2. 转到属性表并找到UpgradeCode属性
  3. 复制属性的 GUID 值UpgradeCode
  4. 在 .wxs 文件中使用该 GUID 作为Product/@UpgradeCode属性。相同的 GUID 将新 MSI 与旧 MSI 相关联。
  5. 用一个元素替换Upgrade.wxs 文件中的MajorUpgrade元素。
  6. 在已安装较新版本的情况下尝试安装旧 MSI 时向元素DowngradeErrorMessage添加一条消息以显示。MajorUpgrade

现在您的升级应该可以工作了。

于 2013-03-15T06:45:36.247 回答