Closed abskulkarni closed 3 months ago
@abskulkarni It has different issues, but a workaround I have used for this situation is to use MSM modules (I have on per folder).
You can recursively include files for each msm module, then include each folder as a "merge" into the main folder. I am missing a lot of context from the previous discussion probably, but that gets around the issue.
An alternative approach is to just manually recurse the folder(s) yourself - the code is not too difficult, and I actually wrote it myself before I figured out how to use the Files
/ DirFiles
(maybe you shouldn't need to call a separate method to "resolve wildcards", I understand having written the recursive routines myself that there are various filtering issues that make this a bit harder, but there's no reason it can't be done ahead of time).
Actually a major issue I have with the API, perhaps a new feature, is that SourceDir
can only be set once per project. So I started using MSM for this exact issue. Later I ended up pulling SourceDir
up to the repo roots, and passing around relative directories more "smartly", but it would be simpler to just be able to specify multiple-per-wixitem SourceDirs.
Hi @oleg-shilo Can you please guide me if there is any solution to my issue above?
As @smaudet suggested, manually recursing through the folders is the most powerful option you have. But it's costly. You have to do recursion heavy lifting:
// pseudo code
foreach(var file in Directory.GetFiles("<your root dir>", "*", SearchOptions.AllFiles))
{
string instalDir = file.GetDirName().MakeRelativeTo(project.SourceDir);
Dir wDir = project.FindOrCreateDir(installDir);
var wFile = new File(file);
wFile.Features = new[] { "<whatever feature you want 1>", "<whatever feature you want 2>" };
wDir.AddFile(new File(wfile));
}
project.Build.Msi();
However, ... dId you try the suggestion I posted in the original thread?
AutoElements.SupportEmptyDirectories = CompilerSupportState.Disabled;
Compiler.AutoGeneration.IgnoreWildCardEmptyDirectories = true;
Not sure I know what you mean, but
Files
will automatically pick all subfolders found. However if you are asking aboutnew Files( new Dir(...
then no.new Dir
can only be inside of te parent dir. Exactly as in the file system.Originally posted by @oleg-shilo in https://github.com/oleg-shilo/wixsharp/issues/1578#issuecomment-2219957171
Hi @oleg-shilo Here the issue is as below: (It will be descriptive explanation about source directory structure. So sorry in advance)
Source Dir structure : I have source directory say named "Database". It has got three sub-folders say "SQL", "MYSQL" & "UPGRADE". Now these sub-folders may have further unlimited number of sub-folders depending on upgrades happening or DB technology being introduced. But in all these sub-folders (level unpredictable) will have .sql files, .dacpac files. Please note, parent/base "Database" folder itself does not have any .sql or .dappac file.
Problem I face : Now through WixSharp MSI, I want to create exact folder structure as that of source directory structure above. There I face difficulty. I have a feature named "Database" in Wix# code which is supposed to install "Database" folder with exact structure as that of source dir. But MSI creates empty folder named "Database" when run, if "Database" feature is not selected.
Workaround I apply is: Place an empty test.sql file in "Database" source base folder itself & compile MSI project. This way I get around empty folder situation. Means, it does not create empty "Database" folder when feature is not selected during installation. But when selected, it also copies this extra test.sql which is not needed,