WiX中TARGETDIR和INSTALLDIR的用法是什么? [英] What is the usage of TARGETDIR and INSTALLDIR in WiX?

查看:32
本文介绍了WiX中TARGETDIR和INSTALLDIR的用法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧版 Visual Studio 部署项目安装程序中,传递为 TARGETDIR 指定值的命令行参数允许我覆盖默认安装位置(我的大部分安装都在没有用户交互的情况下进行,因此命令行自动化被大量使用).但是,我得到的印象是 WiX(默认情况下)将 TARGETDIR 用于不同的东西.虽然我可以(并且将会)更新我们的命令行工具来更改参数名称,但这仍然会留下我们所有需要手动修改的现有安装(一项非常重要的工作).

In legacy Visual Studio Deployment Project installers, passing a command-line parameter that specified a value for TARGETDIR allowed me to override the default installation location (most of my installations take place without user interaction, so command-line automation is used heavily). However, the impression I'm getting is that WiX (by default) uses TARGETDIR for something different. While I can (and will) update our command-line tools to change the parameter name, that still leaves all of our existing installations that would need to be touched manually (a non-trivial effort).

有没有办法通过指定 TARGETDIR 来覆盖 WiX 包中的安装位置而不破坏任何东西?

Is there any way to override the installation location in a WiX package by specifying TARGETDIR without breaking anything?

推荐答案

在进行更多挖掘之后,看起来我以前的经验是特定于 VSDPROJ(可能还有 InstallShield)的行为的结果,而 WiX 符合 Windows 安装程序.

After doing more digging, it looks like my previous experience is a result of behavior specific to VSDPROJ's (and possibly InstallShield), wheras WiX is conforming to the Windows Installer.

正如我在此链接中发现的那样,TARGETDIR 实际上应该代表具有最多可用空间的驱动器的根目录(假设有多个可用空间).这就是为什么 WiX 项目在其下嵌套了用于 Program Files 等的目录.Visual Studio 实际上添加了一个自定义操作,该操作会覆盖此属性到完整安装路径.

As I discovered at this link, TARGETDIR is actually supposed to represent the root of the drive with the most free space available (assuming there's more than one). That's why WiX projects have directories nested under there for Program Files, etc. Visual Studio actually adds a custom action that overrides this property to the full installation path.

我能够通过做两件事来完成我想要的:

I was able to accomplish what I wanted by doing two things:

  1. 将我的所有组件和组件组更改为安装到 TARGETDIR 而不是 INSTALLFOLDER(WiX 放在那里的默认目录)
  2. 添加一个自定义操作,将 TARGETDIR 属性的值设置为安装路径,假设没有从命令行传入.
  1. Change all of my components and component groups to install to TARGETDIR instead of INSTALLFOLDER (the default directory that WiX put in there)
  2. Add a custom action that sets the value of the TARGETDIR property to the installation path, assuming one wasn't passed in from the command line.

为此,我在 <Product> 标签下添加了它:

To do that, I added this under the <Product> tag:

<CustomAction Id="SetTARGETDIR" Property="TARGETDIR" 
              Value="[ProgramFilesFolder][Manufacturer]\[ProductName]" 
              Execute="firstSequence" />

标签中:

<Custom Action="SetTARGETDIR" Before="CostFinalize">TARGETDIR=""</Custom>

这篇关于WiX中TARGETDIR和INSTALLDIR的用法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆