More then one Projekt as InstallerFiles

Nov 17, 2016 at 9:00 AM
Edited Nov 17, 2016 at 11:57 AM
Hey,

I have the Problem that my Projekt has more then one Tool to install at one Progress, so I had with wildcards the two Build Outputpathes and add them to the Installer.
But now I got an ICE30 Exception on Every .dll both projects use, when I add the Dir´s with the Wildcards and ".dll" so its possible to sort them and remove duplicates or is there a Funktion with do this.

For Example:
I have a Programm out of more than one Projekt, all the dll´s I want to add with the Wildcards (*.dll), but some projekts uses the Same dll, so the Installer want to install the same named dll. So is there a way to use the wildcards or have I use File and every DLL explizit.


Thanks for your Help,
Chris
Coordinator
Nov 18, 2016 at 5:58 AM
Hi Chris,

It looks like in your case you cannot use wild cards and have to add the files manually.

Alternatively you can use a filtering lambda with wild yourcard and ignore al the DLLs that are potentially duplicated. And after wildcards are resolved add those ignored dlls explicitly.
Nov 18, 2016 at 6:28 AM
Hi Oleg,

I tried to sort them but I don´t know why but I don´t work like I want this.

For Example I have a Class which returns me the Dir:
var ProgrammDir = new Dir($"%ProgrammFiles%"/{Manufacturer}/{Produkt},
                               new File (MainExe,
                               new FileShortcut("","")),
                               new DirFiles("*.dll", "__Path to the first Outputfolder__"),
                               new DirFiles("*.dll", "__Path to the second Outputfolder__")
                        );

ProgrammDir.DirFileCollections.Distinct();

return ProgrammDir;
Do you have any idea?
Coordinator
Nov 19, 2016 at 11:38 AM
This will not work. There are quite a few wrong things with your code:
  • 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.
You need to use lambdas in the constructor with wildcard:
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"));
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:
var alreadyAdded = new List<string>(); 

Func<string, bool> ifNew = (file)=>
{
    if(alreadyAdded.Contains(file))
        return false;
    alreadyAdded.Add(file);
    return true;
};

var ProgrammDir = new Dir($"%ProgrammFiles%/{Manufacturer}/{Produkt}",
                               new File (MainExe,
                               new FileShortcut("","")),
                               new DirFiles(@"outDir1\.*.dll",  ifNew),
                               new DirFiles(@"outDir2\.*.dll", ifNew)
                        );
Nov 19, 2016 at 1:29 PM
Edited Nov 19, 2016 at 2:19 PM
Hi Oleg,

Thanks for the Help.

But the ifNew generates an error CS1503 : Argument "2": Convert from "System.Func<string, bool>" in "System.Predicate<string>" is not possible.
Coordinator
Nov 21, 2016 at 2:28 AM
Then change it to match the signature exactly:
new DirFiles(@"outDir1\.*.dll",  x=>ifNew(x))
//or
Predicate<string> ifNew = (file)=>