WixSharp 包括应用程序设置,无论谓词如何

WixSharp including appsettings, regardless of predicate

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

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

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

我做错了什么?

我认为这是因为 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)
)

如果您想同时排除“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)
)