How to specify the specific installation directory

Jan 8, 2015 at 8:47 AM
Edited Jan 8, 2015 at 8:50 AM
Hello, currently I am using Wix# to make a setup on Windows 8, but I found a issue.

Here is my code segment.
Dirs = new[]
new Dir(@"PortfolioSurveyor", new Files(@"Files\*")),
new Dir(@"%Desktop%", new ExeFileShortcut("PortfolioSurveyor", @"[INSTALL_DIR]PortfolioSurveyor.exe", ""))

After I ran the msi file on Windows 8, I found all files are installed in the folder E:\PortfolioSurveyor\, actually I would like to install these files in the C:\PortfolioSurveyor. I tried to modify "new Dir(@"PortfolioSurveyor", new Files(@"Files*"))" to "new Dir(@"C:\PortfolioSurveyor", new Files(@"Files*"))", but failed to build. Can you please tell me how to set the installation directory to C:\PortfolioSurveyor?

Jan 9, 2015 at 12:06 AM
Edited Jan 9, 2015 at 12:07 AM
The Wix directory (Wix# Dir target path) doesn't allow absolute path. Thus it has to be done by overriding the INSTALLDIR property prior the installation:
 Project project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(@"Files\Bin\MyApp.exe"),
                    new Dir(@"Docs\Manual",
                        new File(@"Files\Docs\Manual.txt"))),
                new SetPropertyAction("INSTALLDIR", @"C:\My Company\My Product"));

        project.UI = WUI.WixUI_InstallDir;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        Compiler.PreserveTempFiles = true;
However I do see the value in fixing this WiX usability flaw and allowing the direct absolute path. In fact it is exactly in the "Wix# spirit":
            new Project("MyProduct",
                new Dir(@"C:\My Company\My Product",
                    new File(@"Files\Bin\MyApp.exe"),
Thus I have put it in my pending features list so watch for the future releases.
Jan 9, 2015 at 4:15 AM
The issue was fixed, thank you very much.
Jan 19, 2015 at 6:43 AM
Edited Jan 19, 2015 at 6:45 AM
The Release v1.0.4.0 ( has the feature implemented. Now you can just pas the absolute path in the constructor.
Jan 19, 2015 at 1:20 PM
Ok, it's very nice, thank you very much.

发自我的 Windows Phone

发件人: [email removed]
发送时间: ‎2015/‎1/‎19 14:43
收件人: [email removed]
主题: Re: How to specify the specific installation directory [wixsharp:577142]

From: oleg_s

The Release v1.0.4.0 ( has the feature implemented. Now you can just pas the absolute path in the constructor.
Jan 20, 2015 at 10:46 AM
Hi Oleg,

first of all I wnat to thank you for this great project! I really appreciate it. It is the long time missed piece of puzzle.

I just installed version and I tried the absolute paths.

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "company", "productname", "appName");
var installproject = new Project(appName, new Dir(path.....)
installproject.UI = WUI.WixUI_InstallDir;
Compiler.PreserveTempFiles = true;

The result in the wxs File is:

<Directory Id="TARGETDIR" Name="SourceDir" >
<Directory Id="INSTALLDIR" Name="AbsolutePath">
<UIRef Id="WixUI_InstallDir" />
<CustomAction Id="Set_INSTALLDIR_AbsolutePath" Property="INSTALLDIR" Value="C:\Program Files\company\productname\appName" />

The Setup GUI provides the path:

Is there something wrong in my code, or is there a bug in the version

Best regards,
Jan 21, 2015 at 5:13 AM
Edited Jan 21, 2015 at 12:26 PM
Interesting thing is that if you proceed with the installation it will be made into the correct directory.

Nevertheless it is the problem. Apparently setting INSTALLDIR property is not enough (I just learned it). It has to be done either in UI or Execute sequence and the decisions on which one to use cannot be done at compile time. Thus in order to seamlessly use absolute path for all UI levels WiX multiple conditional triggers for CustomAction need to be created. WiX becoming quite ugly for such a simple task. But hey, that is why Wix# was developed.
<CustomAction Id="Set_INSTALLDIR_AbsolutePath" Property="INSTALLDIR" Value="C:\My Company\My Product"  />

<InstallExecuteSequence >
      <Custom Action="Set_INSTALLDIR_AbsolutePath" Before="CostFinalize">(NOT Installed) AND (UILevel &lt; 5)</Custom>

<InstallUISequence >
      <Custom Action="Set_INSTALLDIR_AbsolutePath" Before="CostFinalize">(NOT Installed) AND (UILevel = 5)</Custom>
The problem is addressed in the latest release: Alternatively you can get the fix from NuGet.

No changes in you Wix# script is required.
Jan 22, 2015 at 12:47 PM
Thank you, works great in!
May 8, 2015 at 1:26 PM
Edited May 8, 2015 at 1:27 PM
string Path=@"%ProgramFiles%\MyCompany\MyProduct;
//string Path=@"D:\MyCompany\MyProduct;

 var project = new Project("MyProduct",
                              new Dir(Path,
                                  new Files(@"D:\DeployFolder\*.*")));
Note: "DeployFolder" contain many folder and subfolder.

This Code Works fine but when i change the "Path" to "D:\MyCompany\MyProduct" then it deploy only the first folder file and create a folder name called "D:\ABSOLUTEPATH" and deploy remaining files in this folder.

How can i solve this issue ?
May 8, 2015 at 2:04 PM
Please log it as issue as it is a defect.

As a quick work around use non absolute path abd substitute it with the absolute one in the WxsGenerated event handler. It will be very helpful for you if you have a look and compare the two wxs files generated for both working and not working scenarios.
May 9, 2015 at 9:08 AM
I logged the defect on your behalf:
It is fixed now and the fix will be available with the next release.

Though I would appreciate if you test it prior the release (download 'WixSharp.Samples\WixSharp.dll' from Git). There definitely was a problem with the absolute path but the symptoms were slightly different. That problem is fixed and I am almost positive yours as well. But only your test can confirm it.