Search code examples
c#wixwixsharp

How to install multiple subdirectories under ProgramFiles64Forder with WixSharp?


I have made a WixSharp 64bit installer that should install files under two different directories under "Program Files". Here is a stripped down version of the code:

using System;
using WixSharp;
using File = WixSharp.File;

public class Script {

    public static void Main(string[] args) {
       var project =
           new Project("My Product",
               new Dir(@"%ProgramFiles%",
                   new Dir(@"SubDir1", new File(@"Files\test2.txt")),
                   new Dir(@"SubDir2", new File(@"Files\test2.txt"))
               ));

        project.Platform = Platform.x64;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");    
        Compiler.BuildMsi(project);
}

}

The problem is that the subdirectories will be created under "c:\%ProgramFiles64%\" instead of being under "c:\Program Files\".

If I just install one sub-directory, then the directory will be installed correctly into "c:\Program Files".

If I do the same without specifying the platform as x64 the files will correctly go under "c:\Program Files(x86)".

What am I doing wrong here? How could I get the two directories there.

I first suspected I might be hitting the wrong overload of the Dir constructor, but the behavior is the same when using the following code to ensure it goes into the Dir(string targetPath, params WixEntity[] items) constructor:

           new Dir(@"%ProgramFiles%",new WixEntity[] {
                new Dir(@"SubDir1", new File(@"Files\test2.txt")),
                new Dir(@"SubDir2", new File(@"Files\test2.txt"))
            }

Solution

  • I asked the same question at the Wix# projects page and Oleg_s anwered with a workaround and a good explanation of why it did not work. The answer is here:

    http://wixsharp.codeplex.com/discussions/648259#post1454338