Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add Custom Action in Visual Studio 2010 installer project

I converted a working project from Visual Studio 2008 to VS2010. The c++ solution builds a single executable and 3 DLLs, and a windows installer project.

After converting to VS2010, I received a build error "Unable to build custom action named 'Primary Output from xxxx (Active)' from project output group 'Primary Output' because the project output group does not have a key file."

I removed and re-added the output groups, then attempted to add a custom action. The executable output was not listed as a candidate for a custom action. I then noticed when I selected the executable "Primary Output" properties, that the "KeyOutput" property was set to (None) and was grayed out.

When revisiting the VS2008 version, the KeyOutput property was not grayed out. I found the error message on MSDN, with a useless fix:

"Remove the custom action and replace it with a custom action pointing to a project output group that has a key file."

Obviously the tech writer didn't know how to fix it either. Keep in mind the original build worked and installed correctly. I believe the root issue is why the KeyOutput property is disabled - but why? (When viewing "Outputs" it correctly shows the exe or dll in each project)

like image 615
Roger Dunn Avatar asked Feb 18 '11 19:02

Roger Dunn


People also ask

How do I add a custom action to Visual Studio setup project?

On the Action menu, click Add Custom Action. In the Select Item in Project dialog box, double-click the Application Folder. Select the gadget assembly that was added to the setup project, and then click OK. In the Properties window, make sure that the InstallerClass property is set to True (this is the default).

What is MSI custom action?

The custom actions are the actions that can be performed together with the MSI package install and/or uninstall process. They can be used, for example, to prepare the system for installation of the package, to check prerequisites, to start the application on installation completion, etc.

Where do custom action execute?

Because a custom action can be scheduled in both the UI and execute sequence tables, and can be executed either in the service or client process, a custom action can potentially execute multiple times. Note that the installer: Executes actions in a sequence table immediately by default.


2 Answers

I had a similar problem and I figured out why the setup project could not find the key output files.

My project Output Directory was defined as $(SolutionDir)\bin\$(Platform). SolutionDir already has a trailing backslash so the \bin was placing a double backslash in the path. The project would build fine but the setup project couldn't resolve the key outputs. Setting the output to $(SolutionDir)bin\$(Platform)\ resolved the issue.

like image 64
Don Avatar answered Sep 21 '22 14:09

Don


After further investigation, I found this is a bug in Visual Studio 2010.

If you specify an output name for a project that differs from the name of the project itself, it fails to do the right thing.

To reproduce this, change

Project properties->Linker->General->OutputFile from $(OutDir)$(TargetName)$(TargetExt) to be something like $(OutDir)foobar.exe

The project then changes the KeyOutput value to empty, and is not available for custom actions in installations. No workaround other than living with the default project naming convention.

like image 29
Roger Dunn Avatar answered Sep 17 '22 14:09

Roger Dunn