Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio
All postings are provided AS IS
with no warranties, and confer no rights. Additionally, views expressed
herein are my own and not those of my employer, Microsoft.
I got a question from a customer this week asking how they could modify the default installation path in their MSI-based setup package based on a value they wanted to retrieve from the registry. Typically this kind of modification is desired if your setup shares files/components with another MSI, and that other MSI can be installed to non-default locations by another setup package. The steps to accomplish this are roughly the following. Please note that I am basing this algorithm on how we accomplish this inside of Visual Studio setup (I also described what happens behind the scenes in VS setup in more detail here). There may be alternative ways to accomplish the same result.
I thought it might be worth pointing out that you can do this in Visual Studio without having to use Orca or creating custom build actions.
All you have to do is create a registry file search in the launch conditions with a property name e.g. "MYINSTALLPATH". You then go to the file system browser and select the application folder and change the DefaultLocation to "MYINSTALLPATH".
You can also delete the Install Folder user interface to prevent the user changing the folder.
Hi Owaits - You are correct, this can be done in Visual Studio if you are using a Visual Studio setup/deployment project to create your MSI. The steps that happen behind the scenes in the MSI created by Visual Studio when you install it are essentially the same as what I described in this blog post.