Wix:从C#自定义操作传回属性

问题描述 投票:3回答:2

是否可以从WiX自定义操作传回属性?几个小时以来,我一直在努力寻找解决方案,我看到了很多答案,但是没有一个对我有用。这是我尝试过的,

C#(自定义操作)

public class CustomActions
{
    [CustomAction]
    public static ActionResult TestAction(Session session)
    {
        session["FOO"] = "BAR";
        return ActionResult.Success;
    }
}

WiX FooDlg.wxs

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <Property Id="FOO"/>
    <UI>
      <Dialog Id="FooDlg" Width="370" Height="270" Title="Foo">

        <Control Id="FOO" Type="Edit" Property="FOO" Height="17" Width="45" X="50" Y="150" Text="[FOO]" Indirect="no"/>

        <Control Id="FOO" Type="PushButton" X="150" Y="200" Width="56" Height="17" Text="Test FOO">
          <Publish Event="DoAction" Value="Testing">1</Publish>
        </Control>

      </Dialog>
    </UI>
    <CustomAction Id='FOO' BinaryKey='FooBinary' DllEntry='TestAction' Execute='immediate' Return='check'/>
    <Binary Id='FooBinary' SourceFile='FOO.dll'/>
  </Fragment>
</Wix>
c# windows wix installer windows-installer
2个回答
3
投票

是,您可以从安装程序中的自定义操作传回属性。确保该属性是公共属性(名称中仅使用大写字母),并且您的自定义操作被安排为立即执行,并在您的corespondent对话框加载之前执行(使用详细日志跟踪安装程序执行期间的属性值,只需搜索以获取其中的属性名称)。


0
投票

您需要在Publish标记中指定CustomAction的ID:

<Publish Event="DoAction" Value="FOO">1</Publish>
© www.soinside.com 2019 - 2024. All rights reserved.