Search code examples
c#predicatewixsharp

WixSharp including appsettings, regardless of predicate


Im using WixSharp to build my installer. In my project, I have this :

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

Regardless of that predicate, I still get appsettings.json and appsettings.development.json installed.

What am I doing wrong?


Solution

  • I think it's because lFilename is the name of the file including it's path.

    If it's possible in your case then use Contains

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

    or EndsWith

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