首页 文章

WIX安装程序根目录和版本控制

提问于
浏览
1

我为我的应用程序创建了一个静默安装程序使用WIX . 我希望它将我的应用程序安装到 C:\MyApps 文件夹,但其 Directory Id='TARGETDIR' Name='SourceDir' 标签随机选择C或D驱动器 . 我想仅将我的安装强制执行到C驱动器 . 另外,如果我提供的版本号大于4.0.5,我在安装过程中发现错误"This installation package cannot be installed by the Windows Installer Service. You must install a newer version of the Window Installer service."我正在使用Windows XP专业版SP3版本2002 .

4 回答

  • 0

    您的版本存在的问题是您在更改 Product 版本时正在更改 Windows Installer 版本 .

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

    InstallerVersion 属性应该是安装此软件包所需的 Windows Installer 所需的最低版本 . 你安装了 Windows Installer v4.5 . 当它设置为 406 时,它会查找 Windows Installer v4.6 ,坦率地说,它不存在 . 将其设置为 301 (版本3.1)通常就足够了 .

    InstallerVersion='301'
    

    虽然你的描述属性没问题,但我会发现以下内容更有意义:

    Description="My Product v4.0.6 Installer"
    
  • 4

    首先,我认为你应该用the tutorial available here开始你的WiX之旅 . 它包含了您将要面对的第一件基本问题的答案 . 您还应该意识到,理解WiX意味着首先理解Windows Installer的概念 - 否则某些点对您来说似乎是一种奇怪的魔力 .

    在Visual Studio中创建新的WiX安装项目时,它会生成一个包含一些占位符的模板 . 建议开始修改此模板 . 例如,目录结构:

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

    此代码段定义了ProgramFileFolder下的INSTALLLOCATION文件夹,这是一种比将它放在C:\ root下更好的方法 . 您仍然可以通过在安装时修改INSTALLLOCATION属性来更改安装位置(例如,基于用户的输入) .

    您的问题的快速答案是:

    ...随机挑选C或D驱动器......

    这是预期的 - 它会在安装时选择具有最多可用空间的驱动器 . 如果你坚持WiX模板默认定义的方式,它将属于C :(实际上,在Program Files文件夹下) .

    ...您必须安装较新版本的Window Installer服务...

    基本上,它意味着它所说的 - 您机器上的Windows Installer版本低于您的软件包中所需的版本 . 如果您尝试使用此更改解决上述问题,则它与Windows Installer版本无关 . 只有在您要使用Windows Installer的新功能时,才需要比默认情况下指定的版本更高的版本 .

    希望你能从这个简短的介绍中得出正确的结论 - 从教程开始 . :-)

  • 2

    试试这个:

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

    我认为这应该有效!

  • 2

    不要依赖 TARGETDIR ,并使用自定义属性,如下所示:

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

    该模板取自Yan's answer . 将 INSTALLLOCATION 设置为所需的文件夹 C:\MyApps ,这应该可以解决问题 .

相关问题