0

我使用 WixSharp 构建我的安装程序。在我的项目中,我有这个:

new Files(
    new Feature("RootFilesFeature"),
    Path.Combine(C_SERVICE_RELEASE_PATH,"*.*"),
    (lFilename) => !lFilename.StartsWith("appsettings", true)
)

不管那个谓词如何,我仍然安装了 appsettings.json 和 appsettings.development.json。

我究竟做错了什么?

4

2 回答 2

1

如果您想同时排除“appsettings.json”和“appsettings.development.json”,则必须在它们之间放置 && 而不是 ||

new Files(new Feature("RootFilesFeature"),
    Path.Combine(C_SERVICE_RELEASE_PATH, "*.*"),
    (lFilename) => !lFilename.EndsWith("appsettings.json", true) && 
                   !lFilename.EndsWith("appsettings.development.json", true)
)

于 2021-03-02T15:15:03.970 回答
0

我认为这是因为lFilename文件的名称包括它的路径。

如果您的情况可能,请使用Contains

new Files(
    new Feature("RootFilesFeature"),
    Path.Combine(C_SERVICE_RELEASE_PATH,"*.*"),
    (lFilename) => !lFilename.Contains("appsettings")
)

或者EndsWith

new Files(new Feature("RootFilesFeature"),
    Path.Combine(C_SERVICE_RELEASE_PATH, "*.*"),
    (lFilename) => !lFilename.EndsWith("appsettings.json", true) || 
                   !lFilename.EndsWith("appsettings.development.json", true)
)
于 2021-01-22T13:02:26.653 回答