簡體   English   中英

如何獲取wix屬性值到wix vb自定義操作項目?

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

我在這個&%^&@#$問題上掙扎了兩個多星期,但仍然無法正常工作。 我需要用戶輸入一些數據,並且該數據需要發送到我的WIX VB自定義操作項目。 但是它永遠無法達到。 我目前在WIX中具有以下代碼:

用戶輸入:

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

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

自定義操作和指向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>

在WIX自定義操作項目中,我已經編寫了一個寫入文件的函數,以便可以看到WIX收到了什么。 這只是為了測試值的傳遞,如果值的傳遞有效,我將修改代碼,讓其用.INI文件中用戶的輸入替換特定的文本。

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

當使用所有這些代碼運行安裝程序時,我確實得到了一個包含以下內容的文本文件:text和0。第一個是邏輯的,因為我對它進行了硬編碼,而0是CustomAction1的乘積,這意味着CustomAction已成功結束。 一切都很好,芽,我沒有得到我想要看到的價值。

我確實需要幫助,因為我只是無法正常工作,並且在此問題上花費了大量時間。 萌芽主要是因為這是我能夠部署安裝程序之前的最后一個障礙。

提前致謝,

縮略詞

這里有些錯誤。

  1. 在UI序列和執行序列之間傳遞的屬性必須全部為大寫-這意味着它們是公共的。 還應首先使用Secure ='yes'聲明它們。

  2. 您無需在自定義操作代碼中聲明屬性,而是從安裝過程中獲取它們。 如果您的CA是即時的,您會說類似varname = session [“ VALIDATIONSCRIPT”]的消息,但是它被推遲了,所以這是一個很好的概述:

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

並設置了延遲的CA屬性,您將使用varname = session [“ CustomActionData”]

這也是:

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