如何解决如何使用 Wix# 将构建文件夹的所有内容添加到安装中?
我正在尝试将给定路径的所有输出文件添加到以 .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 Files(clientFolderPath,f => f.EndsWith(".dll")
|| f.EndsWith(".exe")
|| f.EndsWith(".config")),***some other irrellevant stuff***);
}
使用第一种方法,我只从文件夹中获取所有文件,而不是嵌套文件夹及其内容。 使用第二种方法,我什么也得不到。
我该如何解决这些问题,或者有什么完全不同的方法可以让它发挥作用?
谢谢!
解决方法
您可以只使用 Files.FromBuildDir(@"your\build\dir\",".exe|.dll|.config")
。这应该递归地收集所有文件并保留目录结构。您还可以检查相应的 sample 或 Files
类 sources - 存在一些构造函数,这可能也有帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。