After discovering that my Windows Installer package was not correctly setting the InstallLocation value in the registry, I sought to correct it using Visual Studio.
My first reaction was to just set the registry entry myself using the Registry view in the Visual Studio Setup and Deployment project, however the MSDN documentation showed me that the correct way to do it is to use the ARPINSTALLLOCATION property in the installer package. Yet it can’t be a simple property that you set up front as an initial property. It has to be set after the user selects the destination directory. Therefore, it has to be set with a custom action in a proper place in the execution sequence. Unfortunately, you can’t create a simple type 51 custom action using Visual Studio. You can only include an Installer class written in C# or VB that is compiled in your solution. In my research, I discovered a convenient way to add the custom action after the MSI package is built using VB script. Here is the process that I went through:
I added a post build event to the setup and deployment project with the following
cscript "$(ProjectDir)SetArpInstallLocation.vbs" "$(BuiltOuputPath)"
I added the script SetArpInstallLocation.vbs to the deployment project folder. I got this script from the following blog article which was helpful in accomplishing this task.
After building the install package, I checked the program database using Orca.
In the CustomAction table there should be a
SetARPINSTALLLOCATION action with a source of
ARPINSTALLLOCATION and a target of
Also the InstallExecuteSequence table should have a
SetARPINSTALLLOCATION action with a condition of
I installed the application and found that the registry entry was indeed created in the following location
Your results may vary!