This will not work. There are quite a few wrong things with your code:
This is how you filter duplicates and add files explicitly but I am not sure it is what you need. It didn't look like the most elegant solution. May be something like this is a bit better:
- As any LINQ extension method
Distinct
does not modify the collection. You need to reassign it. - Also your
Distinct
will not work anyway as DirFileCollections is a list wild card patterns not the resolved files. -
Wix# doesn't have DirFiles constructor that you specified.
var sharedDLLs = new [] { "shared1.dll", "shared2.dll" }; var ProgrammDir = new Dir($"%ProgrammFiles%/{Manufacturer}/{Produkt}", new File (MainExe, new FileShortcut("","")), new DirFiles(@"outDir1\.*.dll", x => ! sharedDLLs.Contains(Path.GetFileName(x))), new DirFiles(@"outDir2\.*.dll", x => ! sharedDLLs.Contains(Path.GetFileName(x))) ); ... project.ResolveWildCards(); var dir = project.FindDir("whatever"); dir.Files = dir.Files.Add(new File("whatever_dll"));
var alreadyAdded = new List<string>(); Func<string, bool> ifNew = (file)=> { if(alreadyAdded.Contains(file)) returnfalse; alreadyAdded.Add(file); returntrue; }; var ProgrammDir = new Dir($"%ProgrammFiles%/{Manufacturer}/{Produkt}", new File (MainExe, new FileShortcut("","")), new DirFiles(@"outDir1\.*.dll", ifNew), new DirFiles(@"outDir2\.*.dll", ifNew) );