program story

WiX를 사용하여 CustomActionData를 CustomAction에 전달하는 방법은 무엇입니까?

inputbox 2021. 1. 10. 17:13
반응형

WiX를 사용하여 CustomActionData를 CustomAction에 전달하는 방법은 무엇입니까?


지연된 사용자 지정 작업 에서 CustomActionData속성을 설정하는 방법은 무엇입니까?


지연된 사용자 지정 작업은 설치 프로그램 속성에 직접 액세스 할 수 없습니다 ( 참조 ). 사실, CustomActionData재산

session.CustomActionData

여기나열된 기타 메서드 및 속성 은 세션 개체에서 사용할 수 있습니다.

따라서 지연된 사용자 지정 작업 INSTALLLOCATION이. ~ session.CustomActionData. ( 참조참조 참조 )

다음은에서 CustomAction1검색 할 수있는 속성을 설정하는 유형 51 사용자 지정 작업 ( ) 의 예입니다 CustomAction2.

<CustomAction Id="CustomAction1"
              Property="CustomAction2"
              Value="SomeCustomActionDataKey=[INSTALLLOCATION]"
/>

통지 Property속성 이름입니다 CustomAction2. 이것은 중요하다. 유형 51 작업의 속성 속성 값은를 소비하는 사용자 지정 작업의 이름과 같거나 같아야합니다 CustomActionData. (참조 참조 )

속성 키 / 값 쌍 의 이름 SomeCustomActionDataKeyValue보이십니까? 소비 사용자 지정 작업 ( CustomAction2) 의 C # 코드에서 CustomActionData다음 식을 사용하여 해당 속성을 조회 합니다.

string somedata = session.CustomActionData["SomeCustomActionDataKey"];

값을 검색하는 데 사용하는 키 는 유형 51 사용자 지정 작업의 속성 CustomActionData값이 Property아니라 속성 key=value의 키입니다 Value. ( 중요 사항 : CustomActionData사용자 지정 작업의 ID와 이름이 같은 설치 프로그램 속성을 설정하여 채워지지만 CustomActionData키는 설치 프로그램 속성이 아닙니다. ) (참조 참조 )

이 시나리오에서 소비하는 사용자 지정 작업은 아래와 같이 정의 된 지연된 사용자 지정 작업입니다.

<Binary Id="SomeIdForYourBinary" SourceFile="SomePathToYourDll" />
<CustomAction Id="CustomAction2"
              BinaryKey="SomeIdForYourBinary"
              DllEntry="YourCustomActionMethodName"
              Execute="deferred"
              Return="check"
              HideTarget="no"
/>

InstallExecuteSequence 구성

물론 소비 사용자 지정 작업 ( CustomAction2)은 유형 51 사용자 지정 작업 ( CustomAction1) 이후에 실행되어야합니다 . 따라서 다음과 같이 예약해야합니다.

<InstallExecuteSequence>
  <!--Schedule the execution of the custom actions in the install sequence.-->
  <Custom Action="CustomAction1" Before="CustomAction2" />
  <Custom Action="CustomAction2" After="[SomeInstallerAction]" />      
</InstallExecuteSequence>

C ++ schlubs의 경우 다음과 같이 속성을 검색합니다.

MsiGetProperty(hInstall, "CustomActionData", buf, &buflen);

그런 다음 'buf'를 구문 분석합니다. Bondbhai에 감사드립니다 .


사용자 지정 작업에 전달 된 값이 키 / 쌍 집합이 아닌 경우 ...

<SetProperty Id="CustomAction1" Before="CustomAction1" Value="data" Sequence="execute"/>
<CustomAction Id="CustomAction1" BinaryKey="BinaryId" DllEntry="MethodName" Execute="deferred"/>

... 다음을 사용하여 전체 blob을 검색 할 수 있습니다.

string data = session["CustomActionData"];

참조 URL : https://stackoverflow.com/questions/11233267/how-to-pass-customactiondata-to-a-customaction-using-wix

반응형