2012-07-12 15 views
3

如果我在產品塊中編寫下面的代碼,那麼它可以正常工作,但是如果我將它寫入單獨的文件中,則它不起作用。如果位於單獨的文件中,自定義操作不會運行

請誰能告訴我爲什麼會發生這種事?

這是自定義操作單獨的文件代碼:

<?xml version="1.0" encoding="UTF-8"?> 
<?include SetupDefines.wxi?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 

    <!-- The custom action DLL itself.--> 
    <Binary Id="CA" SourceFile="..\bin\debug\Name.CA.dll" /> 

    <CustomAction Id="CustomAction1" 
       BinaryKey="CA" 
       DllEntry="CustomAction1" 
       Execute="immediate" 
       Return="check" /> 

    <!--Custom Actions END--> 
    <InstallExecuteSequence> 

     <Custom Action="CustomAction1" Before="InstallFiles"> 
     <![CDATA[NOT Installed]]> 
     </Custom> 

    </InstallExecuteSequence> 
    </Fragment> 
</Wix> 

回答

7

鏈接器將只包含在解析引用時遇到的片段。

在您的產品wxs中使用CustomActionRef元素以確保鏈接器包含片段。

+0

我並不瞭解CustomActionRef,因爲我總是使用虛擬屬性來提取碎片,但我更喜歡這種解決方案。 – BryanJ 2012-07-13 12:19:09

+0

@BryanJ:虛擬屬性仍然是一個有用的技術,很好的瞭解。我還將它用於不包含可引用的任何內容的片段,例如'Condition'。 – 2012-07-13 12:32:57

相關問題