Reputation: 2035
I have tried to debug my custom action. I put Debugger.Break() into custom action cs. When I build custom action it creates this files:
myCustomAction.dll
myCustomAction.CA.dll
myCustomAction.pdb
In wix project I reference myCustomAction.CA.dll inside binary tags (not myCustomAction.dll). Since there doesn't exists myCustomAction.CA.pdb is this the reason that debugging doesn't work? I have tried also with messagebox and attach to process, when message box is shown. But i get the following message: Cannot find or open the PDB file.
What I'm doing wrong? I have wix 3.5 version and visual studio 2010.
Upvotes: 25
Views: 18949
Reputation: 79
This is in addition to the use of
System.Diagnostics.Debugger.Launch();
In a way to improve the debugging on remote system, like VM. I did some change in the wix targets file used to package the .CA.dll and I have good result.
In the Condition of the first Create Item I added a check for %(ReferenceCopyLocalPaths.extension)' == '.pdb' that way most of my dependencies .pdb are now included im my .CA.dll and allow a easier debug experience on remote system.
C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix.ca.targets
<Target Name="PackCustomAction"
Inputs="@(IntermediateAssembly);@(Content);$(CustomActionContents)"
Outputs="$(IntermediateOutputPath)$(TargetCAFileName)">
<!-- Find all referenced items marked CopyLocal, but exclude non-binary files. -->
<CreateItem
Include="@(ReferenceCopyLocalPaths)"
Condition=" '%(ReferenceCopyLocalPaths.extension)' == '.pdb' or '%(ReferenceCopyLocalPaths.extension)' == '.dll' or '%(ReferenceCopyLocalPaths.extension)' == '.exe'">
<Output TaskParameter="Include" ItemName="CustomActionReferenceContents"/>
</CreateItem>
Upvotes: 1
Reputation: 55601
With DTF custom actions the two techniques are:
1) Put a MessageBox in your custom action and then attach Visual Studio to that process. When attaching, look for rundll32 process with native and CLR loaded.
2) Set the MsiBreak environment variable to the name of your entry point and reboot the machine. DTF will invoke the debugger when that custom action gets called.
Otherwise my general suggestion is to have your entry point be a very thin veneer that connects a reusable class to the MSI. I'll typically create a stand alone class that I can feed data and test everything in a console app and then wire that class up to DTF. I almost never need to debug an installer custom action.
Otherwise I know in general this works.
Upvotes: 5
Reputation: 14037
Here is the article which helped me.
Just add the following code to the first line of your custom action:
System.Diagnostics.Debugger.Launch();
Then just run the installer. When it starts to execute your action, the popup window will appear with proposal to launch visual studio for debugging.
Your reference library is correct, it must be *.CA.dll. Also the approach with MessageBox would work too, but you will need to attach to the rundll32 process.
Upvotes: 68
Reputation: 11023
Not sure what is the problem on your end but here is an article with a sample custom action and a method to debug it. It should work as explained in the following article: http://www.advancedinstaller.com/user-guide/qa-c-sharp-ca.html
Upvotes: 4