4

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>
Damien
  • 1,161
  • 2
  • 19
  • 31
Rikin Patel
  • 8,848
  • 7
  • 70
  • 78

2 Answers2

7

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.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • I didn't know about CustomActionRef because I always used dummy properties to pull in fragments, but I like this solution way better. – BryanJ Jul 13 '12 at 12:19
  • @BryanJ: dummy properties are still a useful technique and good to know about. I also use it for fragments that don't contain anything that can be referred to, e.g. `Condition`. – Wim Coenen Jul 13 '12 at 12:32
3

Your fragment is not being referenced by your project. You can add a dummy property to your fragment and then reference your fragment in your main project file as desribed in this SO answer: WiX: pulling in a CustomTable from a Fragment WITHOUT a CustomAction

Community
  • 1
  • 1
BryanJ
  • 8,485
  • 1
  • 42
  • 61