WixSharp 包括 appsettings,无论谓词如何

问题描述

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

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

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

我做错了什么?

解决方法

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

,

我认为这是因为 lFilename 是包含路径的文件名。

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

new Files(
    new Feature("RootFilesFeature"),(lFilename) => !lFilename.Contains("appsettings")
)

EndsWith

new Files(new Feature("RootFilesFeature"),true) || 
                   !lFilename.EndsWith("appsettings.development.json",true)
)