我有一个自定义操作,需要低于将安装文件夹中的某些部分复制到VS2010文件夹的值
VS2010DEVENV属性)INSTALLLOCATION属性)为了提供足够的权限,我将自定义操作设置为Execute='deferred' Impersonate='no'.但是在运行安装程序时,它会记录以下消息:
无法从非立即自定义操作访问会话详细信息
看来我们无法在"延期"自定义操作中访问属性(即session["VS2010DEVENV"])
有没有其他方法可以根据需要检索这些值?
再一次,我遇到了问题,这可能很容易解决.
我想扩展一个使用WiX创建的设置,以便对已安装程序的配置文件进行更改.为了做到这一点,我创建了一个CustomAction.为了能够更改配置文件,我需要知道它在CustomAction中的(install-)位置.因此,我尝试将INSTALLLOCATION和Filename 传递给我的CustomAction.这就出现了问题:CustomActionData -Attribute始终为空,安装程序抛出异常.
我的CustomAction是一个C#DLL文件:DemoDatumErzeugen.CA.dll.它包含一个DatumEintragen修改配置文件的方法.我试图以这种方式访问数据:
string path = session.CustomActionData["LOCATION"];
Run Code Online (Sandbox Code Playgroud)
这是引发异常的地方.我只得到了德国的错误信息,但它说,沿着线的东西:The supplied key was not found in the dictionary(Der angegebene Schlüssel war nicht im Wörterbuch angegeben.).
这是我尝试将属性从我的setup-script传递到自定义操作的方法:
<Binary Id="DemoDatumEinrichtenCA" SourceFile="DemoDatumErzeugen.CA.dll"/>
<CustomAction Id="DemoDatum.SetProperty" Return="check" Property="DatumEintragen" Value="LOCATION=[INSTALLLOCATION];NAME=StrategieplanConfig.xml;"/>
<CustomAction Id="DemoDatum" BinaryKey="DemoDatumEinrichtenCA" DllEntry="DatumEintragen" Execute="deferred" Return="check" HideTarget="no"/>
<InstallExecuteSequence>
<Custom Action="DemoDatum.SetProperty" After="InstallFiles"/>
<Custom Action="DemoDatum" After="DemoDatum.SetProperty"/>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
我已经看过很多例子,它们以相同的方式完成,或者至少非常相似.我尝试了很多东西,但似乎没有什么比改变价值更有帮助<Custom Action="DemoDatum.SetProperty" After="InstallFiles"/>.CustomActionData始终为零.
我检查一下:session.CustomActionData.Count
我再次感谢任何帮助或暗示我做错了什么.
UPDATE
这已经解决了,所以我已经为未来的读者更新了这篇文章
我在这方面遇到了困难.这里有很多 的 SO文章有关这些设置,但我被卡住了.
我的目标是执行两个步骤:
1)读取将与msi物理一起提供的文件.换句话说,将有三个文件setup.exe,test.msi,specialFile.txt
2)在安装过程中,我想在安装路径中创建一个新文件.C:\ Program Files\MyCompany\MyApplication \newFile.txt
步骤2中的文件是通过读取步骤1中的specialFile.txt中的内容创建的.
我的问题是导航WiX设置的模糊组合,以使我能够读取会话变量并具有足够高的权限来写出文件.这并不容易.
这是解决方案:
<Binary Id="MyCustomAction.CA.dll" SourceFile="path\to\MyCustomAction.CA.dll" />
<CustomAction Id="MyActionsName"
Return="check"
Execute="deferred"
BinaryKey="MyCustomAction.CA.dll"
DllEntry="MyCustomAction"
Impersonate="no"/>
<CustomAction Id="CustomAction1"
Property="MyActionsName"
Value="INSTALLFOLDER=[Get_This_From_Your_Directory_Tag];SOURCEDIR=[SourceDir]"/>
<InstallExecuteSequence>
<Custom Action="CustomAction1" Before="MyActionsName" />
<Custom Action="MyActionsName" Before="InstallFinalize">NOT Installed AND NOT PATCH</Custom>
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)
impersonate="no" 为了有足够的privs来写文件"deferred"为了拥有足够的权限来写入文件Before="InstallFinalize",这是在安装文件之后. 然后在C#代码中,执行以下操作:
string sourceDir = session.CustomActionData["SOURCEDIR"]
string installFolder = session.CustomActionData["INSTALLFOLDER"]
Run Code Online (Sandbox Code Playgroud)
其他有用的参考文献:
本文介绍如何在不使用session ["SourceDir"]的情况下读取SourceDir,因为自定义操作是延迟的.
在延迟(使用impoersonate = no)将值发送到WIX到CA,我使用set属性和值
使用session.CustomActionData ["key"]在CA中收集数据;
有没有办法从CA发回数据到WIX
<Property Id="RESTART" Secure="yes" Value="false" />
Run Code Online (Sandbox Code Playgroud)
我立即使用,
session["RESTART"] = "true"
Run Code Online (Sandbox Code Playgroud)
...如何在延迟CA中实现此目的
我正在使用 dll 来安装打包在 msi 中的驱动程序。当我在 InstallFinalize 之后安排自定义操作时,它会成功,但是如果我在 1) InstallFiles 之后 2) 在 InstallFiles 之后,execute=deferred,3) 在 InstallFiles 之后,execute=deferred,impersonate=no 或 4) 在 InstallFinalize 之前安排它它因 .inf 文件的“找不到文件”而失败。
我已经阅读了This SO post和this page,但仍然不明白我是如何安装我的驱动程序的。
如果我在 InstallFinalize 之后使用,那么如果由于其他原因返回错误,则中止安装为时已晚,并且安装失败。