2017-07-24 143 views
0

我的MSI安装需要是两相。在第一个我收集来自用户的数据,并在第二个我想运行实际安装使用第一阶段收集的值。第二阶段需要在高架环境下运行。Wixsharp - 从ManagedAction传递值ElevatedManagedAction

我在网络上发现,将值传递给高架递延行动的唯一方法是设置属性。在MSDN文章中(以及在网络上的一些示例中),据说我需要

  • set属性[命名与被缓存动作的“主键”相同) - 要传递的值到达被推迟的行动。具体来说,该值可以采用键=值字符串格式的形式,重复和以分号分隔。
  • 在使用索引(通过键)的作用递延取的值。

我开始用行动定义:

project.Actions = new [] 
     { 
      new ManagedAction(InstallerActions.LiveBankInstallPrepare, Return.check, When.After, Step.InstallExecute, 
       Condition.Always, Sequence.InstallExecuteSequence) 
      { 
       ActionAssembly = "%this%", 
       Name = "Preparing installation", 
      }, 
      new ElevatedManagedAction(InstallerActions.LiveBankInstallExecute, Return.check, When.After, Step.InstallExecute, 
       Condition.Always, Sequence.InstallExecuteSequence) 
      { 
       ActionAssembly = "%this%", 
       Name = "Executing installation", 
       Id = "ABCD" 
      }, 
     }; 

在收集的第一个行动的数据我其存储在一个名为一样的递延行动的ID属性

propertyDict = BuildSemicolonSeparatedDict(); 
session["ABCD"] = propertyDict; 

//在运行时propertyDict是如execMode = InstallForced;超时= 5

,我有这样的问题:

什么我做错了,我不能在递延行动见第一步(动作)分配propertyDict。

var execMode = session.CustomActionData["execMode"]; 
//key not found in the dictionary, however propertyDict built in the first action contains it. 

我想我必须传递值错误,当我静态设置的操作参数与UsesProperties财产,我可以看到在递延行动的键值对。

回答

0

没有直接的解决方案,但它为我工作: 在第一个动作我收集一些资料...和序列化的键值对的字符串。比保存到文件。 在第二个操作中,我执行相反的过程 - 读取文件,反序列化 - 并在目标缓存操作中获取值。

0

你需要在你WixSharp项目申报的属性。 例如

project.Properties.Add(new Property("Test", "Test")); 

然后你就可以在你的CustomAction引用它/高架自定义操作

   new ElevatedManagedAction { 
       MethodName = "Test", 
       Return = Return.check, 
       When = When.Before, 
       Step = Step.InstallFinalize, 
       Condition = Condition.NOT_Installed, 
       Impersonate = false, 
       Execute = Execute.deferred, 
       UsesProperties = "Test" 
      } 

现在你应该可以使用它在你的自定义操作/通过MSIRuntime等在UI设置它 那我知道的可能性。