Custom Action not running if located in separate file

custom-action, wix

Solution

The linker will only include fragments that it encounters while resolving references.

Use a CustomActionRef element in your product wxs to ensure that the linker includes the fragment.

Problem

If I write the code below in a product block then it works fine but if I write it in a separate file then it is not working. Please can anyone tell me why this thing happens? This is separate file code for custom action: ``` <?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> ```

Original source