Directories are always created

Feb 19, 2016 at 7:05 AM
I wan't to create a log Folder for each Feature (in my case an Application).
If i put a Dir (log) into a Feature and only a DirPermission under it, this Dir will always be created. Even if the Feature is selected or not.

You can reproduce it. Just extend the Features sample:
   var project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(binaries, @"Files\Bin\MyApp.exe"),
                    new Dir(@"Docs\Manual",
                        new File(docs, @"Files\Docs\Manual.txt"),
                        new File(tuts, @"Files\Docs\Tutorial.txt")),
                   new Dir(docs, "logdocs",   new DirPermission("Everyone", GenericPermission.All) ),
                   new Dir(tuts, "logtuts" ,  new DirPermission("Everyone", GenericPermission.All))));
Feb 19, 2016 at 10:53 PM
You can achieve the desired behavier by associating the permission with the corresponding feature:
new Dir(docs, "logdocs", new DirPermission("Everyone", GenericPermission.All) { Feature = docs }
This does work though the code looks a bit repetitive and I do see here an opportunity for improving the API. The next release will associate the permission either with its own Feature of with the Feature of the parent folder (depending on which one is initialized). And the DirPermission.Feature will be marked as obsolete to prepare it for an imminent phasing out.
Feb 20, 2016 at 12:53 PM
great stuff.
thank you
Feb 21, 2016 at 7:29 AM
Couldn't resist to comment on unrelated topic. :)

I noticed that you are creating a writable directory in "PROGRAMFILES". It is a no-no for a proper deployment solution on Windows. This directory is specifically for hosting the binaries and all software packages supposed to respect that and not to write into it. There are other more suitable locations for writing llogs, configs and so on.