C# 如何使用WixSharp在ProgramFiles64Forder下安装多个子目录?
我制作了一个WixSharp 64位安装程序,它应该在“程序文件”下的两个不同目录下安装文件。下面是代码的精简版本: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",
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))
));