【发布时间】:2021-09-18 01:11:15
【问题描述】:
我正在尝试将给定路径的所有输出文件添加到以 .exe、.dll 或 .config 结尾的安装中,但到目前为止我尝试的方法都没有奏效。
这是我尝试过的:
private static WixEntity[] getContents(string directory)
{
WixEntity[] contents = System.IO.Directory.GetFiles(directory)
.Where(f => f.EndsWith(".dll")
|| f.EndsWith(".exe")
|| f.EndsWith(".config"))
.Select(f => new File(f))
.ToArray();
contents = contents.Concat(System.IO.Directory.GetDirectories(directory, string.Empty, System.IO.SearchOption.TopDirectoryOnly)
.Select(d => new Dir(d.Split('\\').Last(), getContents(d)))
.ToArray()).ToArray();
return contents;
}
private static string buildMsi()
{
var project =
new ManagedProject(productName,
new Dir($"%ProgramFiles%\\{companyName}",
new Dir($"{productName} Files", getContents(clientFolderPath)),
***some other irrellevant stuff***);
}
以及简单地做
private static string buildMsi()
{
var project =
new ManagedProject(productName,
new Dir($"%ProgramFiles%\\{companyName}",
new Dir($"{productName} Files", new Files(clientFolderPath, f => f.EndsWith(".dll")
|| f.EndsWith(".exe")
|| f.EndsWith(".config")),
***some other irrellevant stuff***);
}
使用第一种方法,我只从文件夹中获取所有文件,而不是嵌套文件夹或其内容。 使用第二种方法,我什么也得不到。
我该如何解决这些问题,或者有什么完全不同的方法可以让它工作?
谢谢!
【问题讨论】:
-
我的建议尝试使用递归方法从文件夹和嵌套文件夹中获取所有文件。
-
这不正是我尝试过的吗?由于某种原因,嵌套文件夹没有按照我的方式安装
-
对不起,根据您的问题,我认为您需要那个..然后请正确阅读您的问题并进行编辑..以便其他人可以轻松理解。
-
您是否在 getContens() 方法中获取所有内容?我认为您错过了嵌套文件夹的内容/文件。
-
我递归调用 getContents() 来添加嵌套文件夹的内容。但是在安装过程中,文件夹不是首先创建的
标签: c# installation deployment wix wixsharp