簡體   English   中英

如何使用 Wix# 將構建文件夾的所有內容添加到安裝中?

[英]How to add all contents of build folder to installation using 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 Dir($"%ProgramFiles%\\{companyName}",
                            new Dir($"{productName} Files", 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") 這應該遞歸地收集所有文件並保留目錄結構。 您還可以檢查相應的示例Files- 存在一些構造函數,這可能也有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM