简体   繁体   English

如何获取wix属性值到wix vb自定义操作项目?

[英]how to get wix propery value to wix vb custom action project?

I am struggeling with this &%^&@#$ problem for over two weeks and it is still not working. 我在这个&%^&@#$问题上挣扎了两个多星期,但仍然无法正常工作。 I need the user to input some data and that data needs to be sent to my WIX VB custom action project. 我需要用户输入一些数据,并且该数据需要发送到我的WIX VB自定义操作项目。 however it does never reach it. 但是它永远无法达到。 I currently have the following code in WIX: 我目前在WIX中具有以下代码:

Input of the user: 用户输入:

 <Control Id="InputField" Type="Edit" X="20" Y="100" Width="140" Height="18" Property="ValueAdaptionScript" Text="{40}"/>

Adding the DLL to the installer: 将DLL添加到安装程序:

    <ComponentGroup Id ="DLL" Directory ="INSTALLFOLDER">
  <Component Id ="StringTransfer" Guid ="{479947FA-C324-411C-9B98-083E79C116CB}">
    <File Id ="StringTransfer" KeyPath="yes" Source="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />
  </Component>
</ComponentGroup>

The custom actions and the Binary to point towards the DLL: 自定义操作和指向DLL的二进制文件:

    <Binary Id="StringTransfer" SourceFile="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />

  <CustomAction
      Id="SetProperties"
      Property="ValueAdaptionScript"
      HideTarget="no"
      Value="[MachineIdNumber]"
    />

  <CustomAction
      Id="ValueAdaptionScript"
      BinaryKey="StringTransfer"
      DllEntry="CustomAction1"
      Execute="deferred"
      Impersonate="no"
      Return="check"
    />

  <InstallExecuteSequence>
    <Custom Action="SetProperties" Before="ValueAdaptionScript" />
    <Custom Action="ValueAdaptionScript" Before="InstallFinalize">NOT REMOVE="ALL"</Custom>
  </InstallExecuteSequence>

in the WIX custom action project I have made a function to write to a file so I can see what is being recieved from WIX. 在WIX自定义操作项目中,我已经编写了一个写入文件的函数,以便可以看到WIX收到了什么。 this is just to test the passing of values, if passing of the values work I adapt the code the let it replace a specific piece of text with the input from the user in a .INI file. 这只是为了测试值的传递,如果值的传递有效,我将修改代码,让其用.INI文件中用户的输入替换特定的文本。

the code of the WIX custom action project: WIX自定义操作项目的代码:

Imports System.IO
Imports System.Reflection

Public Class CustomActions
    Public Shared Property MachineIdNumber As String
    Public Shared Property ValueAdaptionScript As String

    <CustomAction()>
    Public Shared Function CustomAction1(ByVal session As Session) As ActionResult
        Dim file As System.IO.StreamWriter
        file = My.Computer.FileSystem.OpenTextFileWriter("c:\test.txt", True)
        file.WriteLine("test")
        file.WriteLine(MachineIdNumber)
        file.WriteLine(ValueAdaptionScript)
        file.WriteLine(CustomAction1)
        file.Close()

        Return ActionResult.Success
    End Function

End Class

when the installer is ran with all this code I do get a text file with the following content: text and 0. the first is logical since i hard coded it and the 0 is the product of CustomAction1 and means that the CustomAction has ended succesfull. 当使用所有这些代码运行安装程序时,我确实得到了一个包含以下内容的文本文件:text和0。第一个是逻辑的,因为我对它进行了硬编码,而0是CustomAction1的乘积,这意味着CustomAction已成功结束。 that is all good and well, bud I don't get the value I would like to see. 一切都很好,芽,我没有得到我想要看到的价值。

I really need help with this, since I just don't get it working and have spent a huge amount of time on this problem. 我确实需要帮助,因为我只是无法正常工作,并且在此问题上花费了大量时间。 bud mainly since this is the last obstacle before I am able to deploy the installer. 萌芽主要是因为这是我能够部署安装程序之前的最后一个障碍。

Thanks in advance, 提前致谢,

FJ 缩略词

There are a few things incorrect here. 这里有些错误。

  1. Properties passsed between the UI sequence and the execute sequence need to be all uppercase - that means they are public. 在UI序列和执行序列之间传递的属性必须全部为大写-这意味着它们是公共的。 They also should be declared first with Secure='yes'. 还应首先使用Secure ='yes'声明它们。

  2. You don't declare propErties in your custom action code, you get them from the installation process. 您无需在自定义操作代码中声明属性,而是从安装过程中获取它们。 If your CA was immediate you'd say something like varname = session["VALIDATIONSCRIPT"] but it's deferred, so this is a good overview: 如果您的CA是即时的,您会说类似varname = session [“ VALIDATIONSCRIPT”]的消息,但是它被推迟了,所以这是一个很好的概述:

http://vadmyst.blogspot.com/2006/05/deferred-custom-actions-with-wix.html http://vadmyst.blogspot.com/2006/05/deferred-custom-actions-with-wix.html

and having set up the deferred CA property you'd use varname = session["CustomActionData"] 并设置了延迟的CA属性,您将使用varname = session [“ CustomActionData”]

and this too: 这也是:

https://www.firegiant.com/wix/tutorial/events-and-actions/at-a-later-stage/ https://www.firegiant.com/wix/tutorial/events-and-actions/at-a-later-stage/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM