WixSharp including appsettings, regardless of predicate

144 views Asked by At

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?

2

There are 2 answers

1
user2250152 On BEST ANSWER

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)
)
0
Gianluca D'Elia On

If you want to exclude both "appsettings.json" and "appsettings.development.json" you have to put && between them and not ||

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