问题描述
我在阅读链接后编写了以下代码: http://blogs.technet.com/b/alexshev/archive/2008/03/25/property-does-not-exist-or-empty-从延迟访问时-custom-action.aspx
I have written this code after reading the link:http://blogs.technet.com/b/alexshev/archive/2008/03/25/property-does-not-exist-or-empty-when-accessed-from-deferred-custom-action.aspx
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Module Id="MergeModule1" Language="1033" Version="1.0.0.0">
<Package Id="cffa568e-1bf0-4eb3-bee3-eb5801a0bbd0" Manufacturer="Microsoft" InstallerVersion="200" />
<Binary Id="myCustomActionsDLL" SourceFile="CustomAction1.CA.dll" />
<CustomAction Id="SetProperty" Execute="immediate"
Property="CA_myCustomAction"
Value="InstallDir=[PRIMARYFOLDER];SourceDir=[SourceDir]" />
<CustomAction
Id="CA_myCustomAction"
BinaryKey="myCustomActionsDLL"
DllEntry="CustomAction1"
Execute="deferred" Impersonate="no"
Return="check" />
<InstallExecuteSequence>
<Custom Action="SetProperty" Before="InstallInitialize">Not Installed</Custom>
<Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
<!--<InstallUISequence>
<Custom Action="CA_myCustomAction" After="CostFinalize"></Custom>
</InstallUISequence>-->
</Module>
</Wix>
我已尝试代替InstallDir - PRIMARYFOLDER
-INSTALLLOCATION,InstallDir,TargetDir,但无法获取为ProgramFiles(x86)下的应用程序指定的安装文件夹.
In place of InstallDir - PRIMARYFOLDER
, I have tried - INSTALLLOCATION, InstallDir, TargetDir but I am unable to get the installation folder specified for the application which is under ProgramFiles(x86).
SourceDir
的值将作为MSI文件运行时所在位置的正确值显示.
The value of the SourceDir
is coming out as proper value where the MSI file is located while it is running.
推荐答案
您的疑难解答应始终从生成和读取详细日志开始.可能同时存在多个问题,并且需要同时解决所有问题.
Your troubleshooting should always start with generating and reading a verbose log. There are probably several problems all at once and all need to be fixed at the same time.
首先,您的Type 51 set属性自定义操作是在InstallInitialize之前安排的.该属性不是安全的自定义属性,因此不会传递到事务中.请尝试在InstallInitialize之后安排它.
First is that your Type 51 set property custom action is scheduled before InstallInitialize. The property is not a secure custom property so it doesn't get passed into the transaction. Try scheduling it after InstallInitialize instead.
第二个是您处于合并模块中,并且合并模块几乎将所有标识符模块化(附加GUID).如果您查看ORCA中的构建合并模块,则会发现它不是在寻找INSTALLDIR,而是在寻找INSTALLDIR.GUID.
Second is you are in a merge module and merge modules modularize (append GUID) pretty much all identifiers. If you look at the build merge module in ORCA you'll see it's not looking for INSTALLDIR it's looking for INSTALLDIR.GUID.
如果确实必须使用INSTALLDIR,则要定义一个不带值的称为INSTALLDIR的属性,并使用SuppressModularization属性来阻止GUID.我通常采用的方法是定义一个MergeRedirectFolder目录,并改用该目录.然后,当我将合并模块添加到InstallShield时,我将该模块与INSTALLDIR关联,然后传递性接管了.
If you really must use INSTALLDIR you want to define a property called INSTALLDIR with no value and use the SuppressModularization attribute to prevent the GUID. The approach I usually take though is to define a MergeRedirectFolder directory and use that instead. Then when I add the merge module to InstallShield I associate the module to INSTALLDIR and the transitive nature then takes over.
可能还有其他问题,但是如果不查看最终的MSI并仔细阅读日志就很难看到.
There may be other problems but it's hard to see without looking at the final MSI and reading through the logs.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Module Id="MergeModule2" Language="1033" Version="1.0.0.0">
<Package Id="c4acbfbc-a0e8-4d52-b516-bee471a76e8a" Manufacturer="" InstallerVersion="200" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="MergeRedirectFolder"/>
</Directory>
<Binary Id="myCustomActionsDLL" SourceFile="CustomAction1.CA.dll" />
<CustomAction Id="SetProperty" Execute="immediate"
Property="CA_myCustomAction"
Value="InstallDir=[MergeRedirectFolder];SourceDir=[SourceDir]" />
<CustomAction Id="CA_myCustomAction"
BinaryKey="myCustomActionsDLL"
DllEntry="CustomAction1"
Execute="deferred" Impersonate="no"
Return="check" />
<InstallExecuteSequence>
<Custom Action="SetProperty" After="InstallInitialize">Not Installed</Custom>
<Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>
</Module>
</Wix>
这篇关于无法通过延迟的自定义操作获取安装位置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!