2

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"))
            }
Jan Mattsson
  • 143
  • 1
  • 7

2 Answers2

2

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

Jan Mattsson
  • 143
  • 1
  • 7
  • The above link of codeplex is moved to github. Work around that worked for me is as follows: var project = new Project("MyApp", new Dir("C:\", new Dir("InstallOne", new DirFiles("E:\files_to_deploy\*.*")), new Dir(InstallTwo"", new DirFiles("E:\files_to_deploy\*.*")) )); – DevCod Jul 02 '18 at 19:33
1
string strLocationOne = "InstallDirOne";
string strLocationTwo = "InstallDirTwo";
string strAllDeployFilesLocation = @"E:\files_to_deploy\*.*"
var project = new Project("MyApp",
                            new Dir(@"C:\", 
                            new Dir(strLocationOne, new DirFiles(strAllDeployFilesLocation)),
                            new Dir(strLocationTwo", new DirFiles(strAllDeployFilesLocation))
                            ));
DevCod
  • 280
  • 2
  • 11