I am trying to inject SQL scripts using WiX toolset's Custom Action when my installer is about to finish.
Product.wxs,
<CustomAction Id="SetMyActionValues" Return="check" Property="MyAction" Value="dbServer=
[DATABASE_SERVER];dbName=[DATABASE_NAME];dbUser=[DATABASE_USERNAME];dbPass=
[DATABASE_PASSWORD];folderPath=[CREATESCRIPTS]"/>
<Binary Id="MyScripts" SourceFile="C:\Users\User\source\repos\Scripts\Scripts\bin\Scripts.CA.dll" />
<CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="MyScripts" DllEntry="CustomAction1"/>
When I set the "FileSource" of the binary entry to absolute path (C:\Users\User\source\repos\Scripts\Scripts\bin\Scripts.CA.dll), it compiled successfully, but gave an error saying dll cannot be found when installation was about to finish.
Next, I tried to reference the Scripts.CA.dll to my WiX project and change the FileSource to just "Scripts.CA.dll". This time, I couldn't compile the project and Visual Studio is telling me the Scripts.CA.dll is missing an assembly manifest.
I am using the latest WiX toolset version, can anyone please point out to me which part has gone wrong?
Thanks a lot.
Assuming you are using c# wix custom action. This issue of 'dll not found' is normally because of overlooking below points -
Your binary file may not have required custom action. A case of wrong binary file used in custom action.
Your custom action name may not match, with what is written in custom action project. This name is case sensitive.
Try below command to identify, if custom action method is present in ca.dll.
Dumpbin.exe comes with Visual Studio C++ development packages. This would list all public custom action methods. Run in Visual Studio Development Command Prompt.
Dumpbin.exe /exports Sample.ca.dll
[CustomAction] public static ActionResult customActionName(Session session) { //Do Action return ActionResult.Success; }
Edit 2 :
We normally dont give absolute path to any file, you can use CA project reference for getting path of ca.dll. Eg. "$(var.CustomActionProjectName.TargetDir)\Scripts.CA.dll". Here CustomActionProjectName is project referenced in installer for custom action. This path could be defined in wxi file for better structuring.
Installer.wxi File
<?define customActionDllPath="$(var.CustomActionProjectName.TargetDir)\Scripts.CA.dl" ?>
CustomAction.wxs
<?include "Installer.wxi"?>
<Binary Id="MyScripts" SourceFile="$(var.customActionDllPath)\Scripts.CA.dll" />