Change Target Install Directory

Aug 23, 2016 at 6:40 PM
Hi! I am using WIX# to create MSI for my project. I set the Install Dir in my code as new Dir(@"inetpub\wwwroot", getDirStructure()),. It is installing the setup files to C:\ drive in Dev environment as there is no other disc available but in the Test environment it is installing the setup files to D:\ drive which is creating issue for me. I tried adding the InstallDir as new Dir(@"C:\inetpub\wwwroot", getDirStructure()),but it gave error whilw building the code as the character ":" not allowed. Please suggest how to fix this. How i can set the default Install Dir to "C:\" drive.

Thanks in advance.
Aug 24, 2016 at 3:15 AM
You can set the install dir to the absolute path as in the InstallDir_AbsolutePath sample:
static public void Main()
    var project = new Project("MyProduct",
                        new Dir(@"D:\MyCompany\MyProduct",
                            new Files(@"files\*.*")));

    project.UI = WUI.WixUI_ProgressOnly;

    Compiler.PreserveTempFiles = true;
BTW your getDirStructure() probably does what '*.*' does so you may want to have a look at "WildCard Files" and particularly "Release Folder" samples.

But most likely you want to change the install dir depending on the runtime conditions. This means that you need to update MSI INSTALLDIR property to your desired location just before MSI runtime starts installing the files. This is what usually MSI GUI does. You can modify your ManagedUI (C#) InstallDir dialog to do the runtime INSTALLDIR assignment.

Though a more reliable approach would be to do it in one of the ManagedSetup events. Have a look at "Setup Events" sample. It does exactly that.