我正在部署包含加密字段的产品在某些配置xml文件中。 安装期间,我正在目标机器上创建一个自签名证书。然后我用它来加密一些字符串,最后我需要将它们存储在配置文件中。如何从WiX中的延期自定义操作获取输出变量?
为了创建证书,我将带有的makecert.exe带到目标安装目录。所以,我需要等到所有文件都复制到目的地后才能运行创建证书的CustomAction。在此之后,其他一些CustomAction正在创建需要存储在配置中的加密值。
这很好,但在这一点上,我想将新值存储在我的配置文件中,但我已经错过了执行XmlFile/XmlConfig的阶段。在MSI日志我看到执行“ExecXmlConfig”行动中的文件被复制之后:
MSI (s) (6C:CC) [02:12:10:898]: Source for file 'makecert.exe' is compressed
InstallFiles: File: makecert.exe, Directory: C:\Program Files (x86)\MyProduct\InstanceFolder\, Size: 60240
MSI (s) (6C:CC) [02:12:10:900]: Executing op: SetTargetFolder(Folder=C:\Program Files (x86)\MyProduct\Nhibernate\)
MSI (s) (6C:CC) [02:12:10:900]: Executing op: SetSourceFolder(Folder=1\o1lebnnf\vemzkq_g\|MyProduct\Nhibernate\)
MSI (s) (6C:CC) [02:12:10:901]: Executing op: FileCopy(SourceName=nw4bpvhi.xml|hibernate.cfg.xml,SourceCabKey=nhibernate.config,DestName=hibernate.cfg.xml,....
MSI (s) (6C:CC) [02:12:10:902]: File: C:\Program Files (x86)\MyProduct\Nhibernate\hibernate.cfg.xml; Won't Overwrite; Won't patch; Existing file is unversioned but modified
MSI (s) (6C:CC) [02:12:10:902]: Executing op: SetTargetFolder(Folder=C:\Program Files (x86)\MyProduct\InstanceFolder\)
MSI (s) (6C:CC) [02:12:10:902]: Executing op: SetSourceFolder(Folder=1\o1lebnnf\|MyProduct\)
MSI (s) (6C:CC) [02:12:10:902]: Executing op: FileCopy(SourceName=7z64.dll,SourceCabKey=Seven7z64.dll,DestName=7z64.dll,Attributes=512,...
MSI (s) (6C:CC) [02:12:10:903]: File: C:\Program Files (x86)\MyProduct\InstanceFolder\7z64.dll; To be installed; Won't patch; No existing file
MSI (s) (6C:CC) [02:12:10:903]: Source for file 'Seven7z64.dll' is compressed
InstallFiles: File: 7z64.dll, Directory: C:\Program Files (x86)\MyProduct\InstanceFolder\, Size: 1484800
MSI (s) (6C:CC) [02:12:10:929]: Executing op: CacheSizeFlush(,)
MSI (s) (6C:CC) [02:12:10:929]: Executing op: ActionStart(Name=ExecXmlConfigRollback,,)
Action 02:12:10: ExecXmlConfigRollback.
MSI (s) (6C:CC) [02:12:10:948]: Executing op: CustomActionSchedule(Action=ExecXmlConfigRollback,ActionType=3329,Source=BinaryData,Target=ExecXmlConfigRollback,...
MSI (s) (6C:CC) [02:12:10:949]: Executing op: ActionStart(Name=ExecXmlConfig,,)
Action 02:12:10: ExecXmlConfig.
MSI (s) (6C:CC) [02:12:10:951]: Executing op: CustomActionSchedule(Action=ExecXmlConfig,ActionType=3073,Source=BinaryData,Target=ExecXmlConfig,CustomActionData=1?C:\Program Files (x86)\MyProduct\Nhibernate\hibernate.cfg.xml?3?0?/hibernate-configuration/session-factory/property[@name='connection.connection_string']????0)
所以,我被困在中间......如果配置我CustomAction运行After='InstallFiles'
它试图执行早在文件被复制之前。 (我错过了正确的事件?)。另一方面,如果我将Actions配置为运行After='InstallFinalize'
- 这太迟了,因为XmlConfig已经触发了,并且没有向配置文件写入任何内容。 理想情况下,我想在安装的最后运行所有这些。
看来愚蠢,我应该需要编写一个CustomAction,做酷似ExecXmlConfig相同的操作只是把它在其他时间......
这里是我的InstallExecuteSequence:
<InstallExecuteSequence>
<!-- Create and Register Certificate on Install -->
<Custom Action='GenerateProductCertificate' After='InstallFiles'><![CDATA[REMOVE<>"ALL"]]></Custom>
<Custom Action='RegisterProductServiceCertificate' After='GenerateProductCertificate'><![CDATA[REMOVE<>"ALL"]]></Custom>
<!-- Create and NHibernate Certificate -->
<Custom Action='GenerateNHibernateCertificate' After='RegisterProductServiceCertificate'><![CDATA[REMOVE<>"ALL"]]></Custom>
<!-- Configure NHibernate XML with Encrypted ConnectionString -->
<Custom Action='GenerateSecureConnectionString' After='GenerateNHibernateCertificate'><![CDATA[(REMOVE<>"ALL")]]></Custom>
</InstallExecuteSequence>
我我使用WiX的3.7(v3.7.1022.0,星期一,2012年10月22日)
我的问题是:
- 有没有办法在我的CustomActions之后重新安排ExecXmlConfig动作来运行 ?
- 如果没有,我可以安排我的CustomActions在复制文件和ExceXmlConfig之间运行吗?
编辑:
一些更多的尝试后,并多一点研究,我可以更准确地定义了我的问题。 我想知道的是:如何从延迟操作中设置一个输出值,以供下一个延迟操作使用?
我的方案迫使我在延迟模式下运行我的自定义操作,因此无法访问会话以存储任何新的变量。但我相信更多的延期行动是安排的,所以我想要做的是找到一种方法将一些变量传递给他们。
您的自定义操作是否推迟?如果您在InstallFiles之后计划延迟的自定义操作,它将在文件安装后触发,这是肯定的。 –
使自定义操作延期解决了时间。但是这些操作的要点是用加密的密码生成一个ConnectionString。名为'GenerateSecureConnectionString'的动作需要将新的ConnectionString返回到一些我想传递给XmlConfig以存储在配置文件中的Property。 但延迟操作无法访问会话 - 所以最终它不能解决我的问题... – Roman