Replies: 4 comments 2 replies
-
Experiment with this sample. It works out of box. But it might be something special about that CommonAppData folder. If you really hit the wall you can always place some generic file (e.g. readme.md) there. Or even delete it at the end of the installation. Though it would be quite hacky. :o) |
Beta Was this translation helpful? Give feedback.
-
I am not sure if it has anything to do with the CommonAppData folder or not but I have tried LegacyDummyAlgorithm and SupportEmptyDirectories with no luck... I was able to leave IgnoreWildCardEmptyDirectories set to the default (false) and set SupportEmptyDirectories to true, and get this to generate in the wxs file which looks like it would/might create the empty folder... <StandardDirectory Id="CommonAppDataFolder">
<Directory Id="MyAppSQL.2" Name="MyAppSQL">
<Component Id="Component.DirPermission" Guid="bf20d6c4-f6a3-41d7-8fd1-f0649c24d154" KeyPath="yes">
<CreateFolder>
<PermissionEx User="Users" ChangePermission="yes" CreateFile="yes" GenericAll="yes" TakeOwnership="no" xmlns="http://wixtoolset.org/schemas/v4/wxs/util" />
</CreateFolder>
<RemoveFolder Id="MyAppSQL.2" On="uninstall" />
</Component>
</Directory>
</StandardDirectory> And after testing it actually does create the empty CommonAppDataFolder\MyAppSQL folder, however it also creates a bunch of other empty folders whose files were excluded using a filter. For example: new Files($".\\SourceDir\\*.*", f =>
!f.Contains(@"\V_")) |
Beta Was this translation helpful? Give feedback.
-
This is kinda expected. If you ask WixSharp to preserve empty directories then it will preserve all of them including autogenerated from wild cards. If you go this way then you need to remove the folders from the setup definition before building msi: project.ResolveWildCards();
// For the sample I remove only the top-level dirs. Though there can be nested ones
project.Dirs = project.Dirs.Where(dir => !dir.Files.Any());
project.BuildMsi(); Alternatively, you can remove empty dirs from the XML. Pseudocode: project.WixSourceGenerated += doc =>
{
doc.FindAll("Directory")
.Where(x =>
{
var comp = x.Element("Component");
return comp.Elements().Count() == 2
&& comp.Element("CreateFolder") != null
&& comp.Element("RemoveFolder") != null;
})
.ForEach(x=>x.Remove());
}; |
Beta Was this translation helpful? Give feedback.
-
Thanks, I ended up using the code below to remove all but a few of the empty directories... project.ResolveWildCards();
string[] ExcludeFromPrune = new string[] {
"Reports",
"SpoolFiles",
"MyAppSQL"
};
IEnumerable<Dir> getEmptyDirs()
{
return project.AllDirs.Where((Dir d) => !d.Files.Any() && !d.Dirs.Any() && !d.Shortcuts.Any() && !Array.Exists(ExcludeFromPrune, e => e == d.Name));
}
IEnumerable<Dir> enumerable;
while ((enumerable = getEmptyDirs()).Any())
{
foreach (Dir dirToRemove in enumerable)
{
project.AllDirs.ForEach(delegate (Dir d)
{
if (d.Dirs.Contains(dirToRemove))
{
d.Dirs = d.Dirs.Except(dirToRemove).ToArray();
}
});
if (project.Dirs.Contains(dirToRemove))
{
project.Dirs = project.Dirs.Except(dirToRemove).ToArray();
}
}
} |
Beta Was this translation helpful? Give feedback.
-
In my setup I have the IgnoreWildCardEmptyDirectories set to true like the following:
But the folder CommonAppDataFolder\MyApp does not get created unless I place a file into it like the DBForm.iss above..., I really do not want the DBForm.iss file to be in the folder and would like to just create an empty folder. Am I missing something or is there a way to create an empty folder?
I don't think IgnoreWildCardEmptyDirectories should have anything to do with the issue but it might...
Beta Was this translation helpful? Give feedback.
All reactions