Windows service setup projects - Unable to build custom action error
I ran into another under-documented snag upgrading my solution to
Visual Studio 2005. It has a Windows service used for behind-the-scenes
maintenance sorts of tasks that run on a regular basis, and a
corresponding setup project. Now, it's also got setup projects for
command-line apps and web apps, and all of those upgraded fairly
well--it got confused on the output, so I had to delete and re-add the
appropriate Primary Output to each project, but after that, all the
setup projects built fine, except the Windows service one.
It gave this error in the Output window when I tried to build it.
Building file 'C:\whatever\MyProjectSetup.msi'...
ERROR: Unable to build custom action named 'Primary output from
MyProject (Release .NET)' because it references an object that has been
removed from the project.
Build process cancelled
In the Error List, when I double-clicked on this error, it took me to
the Custom Actions window for this project. As documented in this Microsoft Knowledge Base article,
the project had the Primary Output listed as a custom action for all
four custom action types--Install, Commit, Rollback, and Uninstall. The
Uninstall one is the only one highlighted, though, with a red wavy
underline. This told me nothing more about the error.
Sometimes in cases like this, when I open the project file in Notepad,
it can make it clear what's wrong. For instance, when a Crystal Reports report
loses its corresponding .cs file, I can reassociate them by manually
editing the project file and reopening the project. But .vdproj files
are different beasts--much uglier and harder to manage in Notepad.
That KB article said it was set up correctly, and yet it wasn't
building. So I tried deleting all four custom actions, and re-adding
them per the directions in the article, and it built,
installed, started and ran, and uninstalled just fine. (For what it's worth, Microsoft did document this process in an MSDN Library article.)
One difference I see is that all my project outputs in all my
setup projects, including these custom actions, now read "(Release Any
CPU)" instead of "(Release .NET)". I'm not sure what difference that
makes, nor why I should care (and have to correct it manually), but as
far as I can see, it's working fine now. We'll see if I get any nasty
surprises when I give it to QA for testing.