0
votes

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. however it does never reach it. I currently have the following code in 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:

    <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:

    <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. 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.

the code of the WIX custom action project:

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. 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,

F.J

1

1 Answers

2
votes

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. They also should be declared first with 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:

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"]

and this too:

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