C# 为什么我在WIX中的托管自定义操作中获得SourceDir的空值?
以下是我正在使用的Product.wxs的代码:C# 为什么我在WIX中的托管自定义操作中获得SourceDir的空值?,c#,.net,wix,windows-installer,custom-action,C#,.net,Wix,Windows Installer,Custom Action,以下是我正在使用的Product.wxs的代码: <Product Id="*" Name="abc" Language="1033" Version="1.0.0.0" Manufacturer="def" UpgradeCode="2b75c560-783e-4688-9a02-da09bf986597"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Product Id="*" Name="abc" Language="1033" Version="1.0.0.0" Manufacturer="def" UpgradeCode="2b75c560-783e-4688-9a02-da09bf986597">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Binary Id="myCustomActionsDLL" SourceFile="..\SetupConfiguration\bin\debug\SetupConfiguration.CA.dll" />
<CustomAction Id="SetProperty" Execute="immediate"
Property="CA_myCustomAction"
Value="InstallDir=[MergeRedirectFolder];SourceDir=[SourceDir]" />
<CustomAction Id="CA_myCustomAction"
BinaryKey="myCustomActionsDLL"
DllEntry="SetABCConfiguration"
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>
<Feature Id="ProductFeature" Title="abc" Level="1">
<ComponentGroupRef Id="ABCGroup" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="def" Name="def">
<Directory Id="dirFC83E07AC2C77525961486C88A01C277" Name="ABC">
<Directory Id="MergeRedirectFolder"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
[CustomAction]
public static ActionResult SetABCConfiguration(Session session)
{
string strSourceFolder = session.CustomActionData["SourceDir"]; // returning blank value
string strWebGeniePhyPath = session.CustomActionData["InstallDir"]; // returning correct value
}
未安装
未安装
[海关行动]
公共静态操作结果集ABC配置(会话)
{
字符串strSourceFolder=session.CustomActionData[“SourceDir”];//返回空值
字符串strWebGeniePhyPath=session.CustomActionData[“InstallDir”];//返回正确的值
}
我故意省略了componentABCGroup
的代码,它只包含一个热收获目录,这是一个很长的列表
请帮忙。我自己通过尝试找到了解决方案: 只需更改以下行:
<Custom Action="SetProperty" After="InstallInitialize">Not Installed</Custom>
未安装
关于这一行:
<Custom Action="SetProperty" After="CreateFolders">Not Installed</Custom>
未安装
它是有效的
我不知道为什么会有这样的更改,因为所讨论的代码在合并模块中而不是在主
Product.wxs
文件中时起作用。默认情况下,WiX不会编写ResolveSource操作,您必须使用将其添加到序列中。但是,我仍然没有在下面的解决方案中添加此ResolveSource元素,它正在工作?请查看Orca中的构建MSI。如果没有完整的源代码、构建安装程序和/或安装程序日志文件,很难说。在第一次安装时有一个隐式的ResolveSource,这就是它的工作原理。如果您已将ResolveSource添加到安装程序中,请确保不会一直调用它,因为它希望原始安装MSI可用。谢谢,Phil。知道SDK中隐式调用在哪里被记录了吗?Chris,我不认为它被记录了,一些MSI的家伙在一次谈话中说了,或者告诉我。我觉得这是一件值得归档的有用的东西。