在 WiX 中更改 TARGETDIR [英] Changing the TARGETDIR in WiX

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

问题描述

我在设置 TARGETDIR 路径时遇到问题.我使用 dark.exe 对一个有效的 MSI 文件进行逆向工程并阅读我能找到的关于这个主题的任何帖子,但我似乎无法将 TARGETDIR 设置为指向路径 ProgramFiles\制造商\产品.以下是我的 WXS 文件的提炼,它导致我的应用程序出于某种原因安装到我的 D 驱动器的根目录:

I am having problems setting the TARGETDIR path. I used dark.exe to reverse engineer a working MSI file and read any posts I could find on this subject, but I seem to be unable to set the TARGETDIR to point to the path ProgramFiles\Manufacturer\Product. Below is a distilation of my WXS file which results in my application being installed to the root of my D-drive for some reason:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*"
             Name="FBL - Some App"
             Language="1033"
             Version="1.0.0.0"
             Manufacturer="Foo &amp; Bar Limited"
             UpgradeCode="780286c6-e064-4402-80d8-dd2c68b56c04">
        <Package InstallerVersion="200"
                 Compressed="yes"
                 InstallScope="perMachine"
                 Comments="Performs some operation that is important" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <Media Id="1" Cabinet="App.1.0.0.cab" EmbedCab="yes" />
        <CustomAction Id="setTARGETDIR"
                      Property="TARGETDIR"
                      Value="[ProgramFilesFolder][Manufacturer]\[ProductName]"
                      Execute="firstSequence"
                      Return="check" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Component Id="C__App.exe"
                       Guid="{074586E9-A675-2734-A4CD-1CE520922A41}">
                <File Id="F__App.exe"
                      Name="App.exe"
                      KeyPath="yes"
                      Assembly=".net"
                     AssemblyManifest="F__App.exe"
                      AssemblyApplication="F__App.exe"
                      DiskId="1"
                      Source="D:\SomePath\bin\Debug\App.exe" />
            </Component>
        </Directory>
        <Feature Id="DefaultFeature" ConfigurableDirectory="TARGETDIR" Level="1">
            <ComponentRef Id="C__App.exe" Primary="yes" />
        </Feature>
        <Icon Id="favicon.ico" SourceFile="d:\SomePath\favicon.ico" />
        <Property Id="ARPPRODUCTICON" Value="favicon.ico" />
        <UI />
        <InstallExecuteSequence>
            <Custom Action="setTARGETDIR" Before="CostFinalize" />
        </InstallExecuteSequence>
    </Product>
</Wix>

我确定我遗漏了一些简单的东西,但我无法从这里找到有关该做什么的更多信息.

I'm sure I am missing something simple, but I cannot find any further information on what to do from here.

推荐答案

需要进行以下修改:

<CustomAction Id="SetTARGETDIR"
              Directory="TARGETDIR"
              Value="[ProgramFilesFolder][Manufacturer]\[ProductName]"
              Return="check" />

<InstallExecuteSequence>
    <Custom Action="SetTARGETDIR" After="InstallValidate" />
</InstallExecuteSequence>

说明:使用 Directory 属性而不是属性(它是类型 35 的自定义操作)并在执行序列中的 InstallValidate 之后安排此操作 - 那是检查目录的写访问权限并真正设置的时间.

Explanation: Use the Directory attribute instead of a property (it's a type 35 custom action) and schedule this action after InstallValidate in the execute sequence - that's when directories are checked for write access and truly set.

(感谢来自 WiX 用户组的 Narina Chandra Sekhar 对此的回答.)

(Thanks to Narina Chandra Sekhar, from the WiX user group for the answer on this.)

这篇关于在 WiX 中更改 TARGETDIR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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