新的一天,新的问题;-)仍然需要与自定义的行动斗争.我已经管理它来调用自定义操作并将一些测试数据传递给它.现在我想用我需要的真实数据替换testdata.这里的问题开始:我想调用一个批处理文件,它被安装在我的安装的子目录中.因此,我需要将安装路径传递给自定义操作. Afaik这可以使用customactiondata机制来完成.但这不行.当我记录安装时,我可以看到,在定制操作INSTALLLOCATION之外指向正确的路径,但是一旦我查看customaction,customactiondata属性是空的…
任何人都可以看看我的代码,并给我一个提示我做错了什么?感谢你的好意!
<Module Id="DflHelpInstaller" Language="1033" Version="1.0.0.0"> <Package Id="f952de58-1dc6-46b3-872a-7a49e2d9ea0a" Manufacturer="DflHelpInstaller" InstallerVersion="200" /> <Binary Id='RegisterDflHelpDll' SourceFile="$(var.REGISTERHELP.TargetDir)RegisterDflHelp.CA.dll" /> <CustomAction Id='RegisterDflHelp' BinaryKey='RegisterDflHelpDll' DllEntry='RegisterDflHelp' Execute='deferred' /> <CustomAction Id="RegisterDflHelp.SetProperty" Return="check" Property="RegisterDflHelp" Value='[INSTALLLOCATION]' Execute='immediate' /> <InstallExecuteSequence> <Custom Action='RegisterDflHelp.SetProperty' After='CostFinalize' /> <Custom Action='RegisterDflHelp' After='InstallFiles' /> </InstallExecuteSequence> <Directory Id="TARGETDIR" Name="SourceDir"> </Directory> <ComponentGroupRef Id="HelpGroup"/> </Module> </Wix>@H_301_6@使用MergeModule的安装程序的大纲:
….
<Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder" SourceName="PFFiles"> <Directory Id="Company" Name='$(var.COMPANY)'> <Directory Id="INSTALLLOCATION" SourceName='$var.v[SDK_VERSION]'> <Component Id="MyBanner" Guid="C8C28B92-9326-4991-BFB1-BBDFDF3653AB"> <File Id ="Banner.bmp" Source="Banner.bmp" KeyPath="yes" DiskId="1"/> </Component> <Merge Id ="DflHelpInstaller" SourceFile="DflHelpInstaller.msm" Language="1033" DiskId="1" /> </Directory> </Directory>@H_301_6@….
<Feature Id="Complete" Title="Setup" Description="Installs the SDK on your local machine." Display="expand" Level="1" ConfigurableDirectory="INSTALLLOCATION"> <ComponentRef Id="Banner" /> <ComponentRef Id ="UNINSTALLER"/> <ComponentGroupRef Id="ReferenceGroup"/> <MergeRef Id="DflHelpInstaller"/> </Feature>@H_301_6@CustomAction:
public class CustomActions { [CustomAction] public static ActionResult RegisterDflHelp(Session session) { session.Log("Begin CustomAction1"); session.Log("Before Access to customactiondata"); //should contain the installation path - unfortunatelly it is empty! why? string cad = session["CustomActionData"]; Debugger.Break(); RegisterHelp(cad); session.Log("End of custom action.."); return ActionResult.Success; }@H_301_6@
如果你描述你的数据…
原文链接:https://www.f2er.com/windows/363714.html<CustomAction Id="MyCustomActionData" Return="check" Property="MyCustomAction" Value='PROPERTY0=[PROPERTY0];PROPERTY1=[PROPERTY1];PROPERTY2=[PROPERTY2]' Execute='immediate' />@H_301_6@您可以访问以下数据:
string property0 = session.CustomActionData["Property0"]; string property1 = session.CustomActionData["Property1"]; string property2 = session.CustomActionData["Property2"];@H_301_6@在上一个例子中,您将使用:
<CustomAction Id="RegisterDflHelp.SetProperty" Return="check" Property="RegisterDflHelp" Value='INSTALLLOCATION=[INSTALLLOCATION]' Execute='immediate' />@H_301_6@然后
string cad = session.CustomActionData["INSTALLLOCATION"];@H_301_6@