【发布时间】:2020-03-26 21:45:51
【问题描述】:
我有一个应该安装我的 c# 应用程序的 Wix 项目。文件复制和防火墙例外已经在起作用。现在我想用自定义操作修改 json 配置文件。我想读取所有 json 文件,更改一些值并将它们写回程序文件。这是我的 CA 定义:
<CustomAction Id="PrepareConfigurationFilesCustomAction" BinaryKey="InstallerCA" DllEntry="PrepareConfigurationFilesCustomAction" Execute="immediate" Impersonate="no" Return="check" />
<CustomAction Id="CreateConfigurationFiles" BinaryKey="InstallerCA" DllEntry="CreateConfigurationFiles" Execute="deferred" Impersonate="no" Return="check" />
<Custom Action="PrepareConfigurationFilesCustomAction" Before="CreateConfigurationFiles">NOT Installed AND NOT REMOVE</Custom>
<Custom Action="CreateConfigurationFiles" Before="InstallFinalize">NOT Installed AND NOT REMOVE</Custom>
如果我打开 .msi wirth Orca,Actios 的顺序似乎是正确的。
InstallFiles 4000
PrepareConfigurationFilesCustomAction NOT Installed AND NOT REMOVE 6598
CreateConfigurationFiles NOT Installed AND NOT REMOVE 6599
但是当我运行 .msi 时出现异常
Excetion TrownSystem.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\Vendor\Product\etc\Configurations'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.GetFiles(String path)
at Vendor.Application.Product.Setup.Actions.CustomActionData.ConfigurationFilesCustomActionData.CreateSessionCustomActionData(Session session) in C:\work\\Projects\Installation\Packages\Product.Workstation\Setup.Actions\CustomActionData\ConfigurationFilesCustomActionData.cs:line 99
当我附加调试器时,我可以在代码和文件系统中看到文件不存在。
如果我将第一个 Ca (PrepareConfigurationFilesCustomAction) 更改为 Execute="deferred",则会写入文件但我无法访问会话值...
对我有什么想法或解决方案吗?
谢谢!
【问题讨论】:
标签: c# wix windows-installer custom-action