0

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?

WynDiesel
  • 1,104
  • 7
  • 38

2 Answers2

1

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)
)

0

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)
)
user2250152
  • 14,658
  • 4
  • 33
  • 57
  • So your code didn't exactly work as is (I still needed that path in), but you were right; the filename was not only the filename, but the entire path. When I changed my predicate to contains, it worked. – WynDiesel Jan 22 '21 at 13:13