如何使用 WixSharp 在 ProgramFiles64Forder 下安装多个子目录?
How to install multiple subdirectories under ProgramFiles64Forder with WixSharp?
我制作了一个 WixSharp 64 位安装程序,它应该在 "Program Files" 下的两个不同目录下安装文件。这是代码的精简版本:
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:\Program Files\".
下创建
如果我只安装一个子目录,那么该目录将正确安装到"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 回答了一个解决方法,并很好地解释了为什么它不起作用。答案在这里:
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))
));
我制作了一个 WixSharp 64 位安装程序,它应该在 "Program Files" 下的两个不同目录下安装文件。这是代码的精简版本:
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:\Program Files\".
下创建如果我只安装一个子目录,那么该目录将正确安装到"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 回答了一个解决方法,并很好地解释了为什么它不起作用。答案在这里:
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))
));