Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用WixSharp在ProgramFiles64Forder下安装多个子目录?_C#_Wix_Wixsharp - Fatal编程技术网

C# 如何使用WixSharp在ProgramFiles64Forder下安装多个子目录?

C# 如何使用WixSharp在ProgramFiles64Forder下安装多个子目录?,c#,wix,wixsharp,C#,Wix,Wixsharp,我制作了一个WixSharp 64位安装程序,它应该在“程序文件”下的两个不同目录下安装文件。下面是代码的精简版本: using System; using WixSharp; using File = WixSharp.File; public class Script { public static void Main(string[] args) { var project = new Project("My Product",

我制作了一个WixSharp 64位安装程序,它应该在“程序文件”下的两个不同目录下安装文件。下面是代码的精简版本:

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);
}
}

问题是子目录将在“c:\%ProgramFiles64%\”下创建,而不是在“c:\ProgramFiles\”下创建

如果我只安装一个子目录,那么该目录将正确安装到“c:\Program Files”中

如果我在没有将平台指定为x64的情况下执行相同操作,则文件将正确地放在“c:\Program files(x86)”下

我做错了什么?我怎样才能得到那里的两个目录

我首先怀疑我可能遇到了Dir构造函数的错误重载,但使用以下代码确保它进入Dir(string targetPath,params WixEntity[]items)构造函数时的行为是相同的:

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

我在Wix项目页面上问了同样的问题,Oleg#s回答了一个变通方法,并很好地解释了为什么它不起作用。答案如下:


codeplex的上述链接已移动到github。对我有效的解决方法如下:var project=new project(“MyApp”、new Dir(“C:\”、new Dir(“InstallOne”、new DirFiles(“E:\files\u to\u deploy*”)、new Dir(InstallTwo)”、new DirFiles(“E:\files\u to\u deploy*”);
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))
                            ));