我想使用自定义操作来设置属性,然后立即使用新设置的属性值来更新目录。到目前为止,我有一个自定义操作,使用WMI查找单独产品的安装路径,并将属性设置为该值。当我转身并使用该属性设置目录时,我得到旧的/默认值而不是新的属性值。
上下文:
我有一个像这样的目录结构:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="pf">
<Directory Id="CompanyName" Name="$(var.companyName)">
<Directory Id="FooProductName" Name="$(var.prodName)">
<Directory Id="INSTALL_DIR">
<Directory Id="PRODUCT_ROOT">
</Directory>
<Directory Id="FOO_DIR" Name="NotInstalled">
<Directory Id="FOO_BINDIR" Name="bin" />
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
我声明的属性如下:
<Property Id="FOO_INSTALLLOCATION_CHECK_0" Value="AProductName" />
<Property Id="FOO_INSTALLLOCATION_DIR_0" Value="NotInstalledHere" />
我有这样声明的自定义操作:
<CustomAction Id="FooMoveFooDir" Directory="FOO_DIR" Value="[FOO_INSTALLLOCATION_DIR_0]" />
<CustomAction Id="GetInstallLocation" Return="check" BinaryKey="FooCAInstallLoc" DllEntry="GetInstallLocation" Execute="immediate" />
GetInstallLocation使用WMI搜索包含FOO_INSTALLLOCATION_CHECK_0中值的已安装产品,并将FOO_INSTALLLOCATION_DIR_0设置为该值。它完成了这一点在下面的日志记录片段中得到证实。
我在&lt; InstallExecuteSequence&gt;
中有以下内容<Custom Action="FooMoveFooDir" After="CostFinalize">1</Custom>
<Custom Action="GetInstallLocation" Before="FooMoveFooDir">1</Custom>
记录看起来像这样(来自WiLogUtil):
(UNKNOWN) Action ended 11:59:35: CostFinalize. Return value 1.
(SERVER) MSI (s) (20:4C) [11:59:35:643]: Doing action: GetInstallLocation
(UNKNOWN) Action 11:59:35: GetInstallLocation.
(UNKNOWN) Action start 11:59:35: GetInstallLocation.
(SERVER) MSI (s) (20:98) [11:59:35:665]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI2105.tmp, Entrypoint: GetInstallLocation
(SERVER) MSI (s) (20:E4) [11:59:35:666]: Generating random cookie.
(SERVER) MSI (s) (20:E4) [11:59:35:667]: Created Custom Action Server with PID 8872 (0x22A8).
(SERVER) MSI (s) (20:34) [11:59:35:685]: Running as a service.
(SERVER) MSI (s) (20:34) [11:59:35:687]: Hello, I'm your 32bit Impersonated custom action server.
(UNKNOWN) SFXCA: Extracting custom action to temporary directory: C:\Windows\Installer\MSI2105.tmp-\
(UNKNOWN) SFXCA: Binding to CLR version v4.0.30319
(UNKNOWN) Calling custom action FOO.BAR.Installer.CustomActions.InstallLocation!FOO.BAR.Installer.CustomActions.InstallLocation.CustomActions.GetInstallLocation
(UNKNOWN) Starting GetInstallLocation
(SERVER) MSI (s) (20:34) [11:59:35:813]: Running as a service.
[ ... snip ... ]
(SERVER) MSI (s) (20:A8) [11:59:40:635]: Running as a service.
(UNKNOWN) Changing FOO_INSTALLLOCATION_DIR_0's value to 'C:\Program Files (x86)\FOO Company\AProductName\
(UNKNOWN) FOO_INSTALLLOCATION_DIR_0 = 'C:\Program Files (x86)\FOO Company\AProductName\'
(SERVER) MSI (s) (20:24) [11:59:40:664]: Running as a service.
[ ... snip ... ]
(SERVER) MSI (s) (20:24) [11:59:44:420]: Running as a service.
(UNKNOWN) Action ended 11:59:44: GetInstallLocation. Return value 1.
(SERVER) MSI (s) (20:4C) [11:59:44:465]: Doing action: FooMoveFooDir
(UNKNOWN) Action 11:59:44: FooMoveFooDir.
(UNKNOWN) Action start 11:59:44: FooMoveFooDir.
(SERVER) MSI (s) (20:4C) [11:59:44:467]: Note: 1: 1314 2: NotInstalledHere
(SERVER) MSI (s) (20:4C) [11:59:44:467]: Note: 1: 1606 2: NotInstalledHere
(UNKNOWN) Error 1606. Could not access network location NotInstalledHere.
它将目录FOO_DIR设置为FOO_INSTALLLOCATION_DIR_0的默认值,而不是前一步骤中自定义操作设置的值。搜索指示如何将目录设置为属性值以及如何使用c#中的自定义操作设置属性,但没有找到答案。
答案 0 :(得分:0)
可能你已经尝试过了,但无论如何。不是使用自定义操作直接设置DIrectory Id,而是通过属性设置值。
<Property Id="Foo_INSTALLDIR" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="[Foo_INSTALLDIR]" Name="[Foo_INSTALLDIR]">
</Directory>
</Directory>
了解我如何使用目录 * Id =“[Foo_INSTALLDIR]”*
检查并告诉我们!