diff --git a/Confuser.CLI/Program.cs b/Confuser.CLI/Program.cs
index 2586fff31..0bc1451ab 100644
--- a/Confuser.CLI/Program.cs
+++ b/Confuser.CLI/Program.cs
@@ -60,8 +60,7 @@ static int Main(string[] args) {
try {
var xmlDoc = new XmlDocument();
xmlDoc.Load(files[0]);
- proj.Load(xmlDoc);
- proj.BaseDirectory = Path.Combine(Path.GetDirectoryName(files[0]), proj.BaseDirectory);
+ proj.Load(xmlDoc, Path.GetDirectoryName(files[0]));
}
catch (Exception ex) {
WriteLineWithColor(ConsoleColor.Red, "Failed to load project:");
diff --git a/Confuser.Core/Project/ConfuserProject.cs b/Confuser.Core/Project/ConfuserProject.cs
index d8dc25a54..6c673d9fd 100644
--- a/Confuser.Core/Project/ConfuserProject.cs
+++ b/Confuser.Core/Project/ConfuserProject.cs
@@ -626,7 +626,7 @@ public XmlDocument Save() {
///
/// The project XML contains schema errors.
///
- public void Load(XmlDocument doc) {
+ public void Load(XmlDocument doc, string baseDirRoot = null) {
doc.Schemas.Add(Schema);
var exceptions = new List();
doc.Validate((sender, e) => {
@@ -641,7 +641,11 @@ public void Load(XmlDocument doc) {
OutputDirectory = docElem.Attributes["outputDir"].Value;
BaseDirectory = docElem.Attributes["baseDir"].Value;
-
+ if (!string.IsNullOrEmpty(baseDirRoot))
+ {
+ BaseDirectory = Path.Combine(baseDirRoot, BaseDirectory);
+ }
+
if (docElem.Attributes["seed"] != null)
Seed = docElem.Attributes["seed"].Value.NullIfEmpty();
else
@@ -674,13 +678,45 @@ public void Load(XmlDocument doc) {
PluginPaths.Add(i.InnerText);
}
else {
- var asm = new ProjectModule();
- asm.Load(i);
- Add(asm);
+ AddModule(i);
}
}
}
+ internal void AddModule(XmlElement elem) {
+ if (IsWildcard(elem.Attributes["path"].Value)) {
+ BatchLoadModules(elem);
+ }
+ else {
+ var asm = new ProjectModule();
+ asm.Load(elem);
+ Add(asm);
+ }
+ }
+
+ internal bool IsWildcard(string path) {
+ return !string.IsNullOrEmpty(path) && path.Contains(@"*");
+ }
+
+ internal bool BatchLoadModules(XmlElement elem) {
+ string wildCardPath = elem.Attributes["path"].Value;
+ string[] files = Directory.GetFiles(BaseDirectory, wildCardPath, SearchOption.TopDirectoryOnly);
+ if (files.Length <= 0)
+ {
+ return false;
+ }
+
+ var asmPrototype = new ProjectModule();
+ asmPrototype.Load(elem);
+
+ foreach (string fileName in files) {
+ var moduleEntry = asmPrototype.Clone();
+ moduleEntry.Path = fileName;
+ Add(moduleEntry);
+ }
+
+ return true;
+ }
///
/// Clones this instance.
///