3 回答

TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊
延遲的自定義操作無(wú)法直接訪(fǎng)問(wèn)安裝程序?qū)傩裕ㄒ茫?。?shí)際上,只有CustomActionData財(cái)產(chǎn)
session.CustomActionData
以及此處列出的其他方法和屬性在會(huì)話(huà)對(duì)象上可用。
因此,對(duì)于檢索諸如之類(lèi)的屬性的延遲自定義操作INSTALLLOCATION,您必須使用類(lèi)型51自定義操作(即設(shè)置屬性自定義操作)來(lái)傳遞該信息,并且您將使用CustomAction的C#代碼中的數(shù)據(jù)通過(guò)session.CustomActionData。(見(jiàn)參考和參考)
下面是51類(lèi)自定義動(dòng)作(CustomAction1)的示例,它將設(shè)置可以在其中檢索的屬性CustomAction2。
<CustomAction Id="CustomAction1"
Property="CustomAction2"
Value="SomeCustomActionDataKey=[INSTALLLOCATION]"
/>
請(qǐng)注意,Property屬性名稱(chēng)是CustomAction2。這個(gè)很重要。類(lèi)型51操作的屬性屬性值必須與正在使用的自定義操作的名稱(chēng)相同/相同CustomActionData。(見(jiàn)參考)
注意名稱(chēng)SomeCustomActionDataKey的Value屬性鍵/值對(duì)?在使用自定義操作(CustomAction2)中的C#代碼中,您將CustomActionData使用以下表達(dá)式查找該屬性:
string somedata = session.CustomActionData["SomeCustomActionDataKey"];
用于從中檢索值的鍵CustomActionData不是Property類(lèi)型51自定義操作的屬性值,而是屬性中key=value對(duì)的鍵Value。(重要內(nèi)容:CustomActionData通過(guò)設(shè)置與消費(fèi)自定義操作的ID同名的安裝程序?qū)傩詠?lái)填充,但CustomActionData鍵不是安裝程序?qū)傩浴#ㄕ?qǐng)參閱參考資料)
在我們的場(chǎng)景中,消費(fèi)自定義操作是一個(gè)延遲的自定義操作,定義方式如下所示:
<Binary Id="SomeIdForYourBinary" SourceFile="SomePathToYourDll" />
<CustomAction Id="CustomAction2"
BinaryKey="SomeIdForYourBinary"
DllEntry="YourCustomActionMethodName"
Execute="deferred"
Return="check"
HideTarget="no"
/>
配置InstallExecuteSequence
當(dāng)然,消費(fèi)自定義action(CustomAction2)必須在51自定義動(dòng)作(CustomAction1)之后運(yùn)行。所以你必須像這樣安排他們:
<InstallExecuteSequence>
<!--Schedule the execution of the custom actions in the install sequence.-->
<Custom Action="CustomAction1" Before="CustomAction2" />
<Custom Action="CustomAction2" After="[SomeInstallerAction]" />
</InstallExecuteSequence>

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊
對(duì)于我們C ++ schlubs,您可以按如下方式檢索Property:
MsiGetProperty(hInstall, "CustomActionData", buf, &buflen);
然后你解析'buf'。謝謝Bondbhai。
- 3 回答
- 0 關(guān)注
- 942 瀏覽
添加回答
舉報(bào)