diff --git a/GameBundle/Options.cs b/GameBundle/Options.cs
index 6fd0234..b49553f 100644
--- a/GameBundle/Options.cs
+++ b/GameBundle/Options.cs
@@ -37,8 +37,6 @@ namespace GameBundle {
public string LibFolder { get; set; }
[Option('n', "name-builds", HelpText = "Name the build output directories by the project's name")]
public bool NameBuilds { get; set; }
- [Option('d', "display-name", HelpText = "The name that should be used for named builds and the mac app bundle instead of the project's name")]
- public string DisplayName { get; set; }
[Option('a', "build-args", HelpText = "Additional arguments that should be passed to the dotnet publish command")]
public string BuildArgs { get; set; }
diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs
index b29d3c4..026d503 100644
--- a/GameBundle/Program.cs
+++ b/GameBundle/Program.cs
@@ -117,13 +117,29 @@ namespace GameBundle {
}
private static void CreateMacBundle(Options options, DirectoryInfo dir, FileInfo proj) {
- var app = dir.CreateSubdirectory($"{GetDisplayName(options, proj)}.app");
+ var files = dir.GetFiles();
+ var dirs = dir.GetDirectories();
+
+ // figure out the app name, which should match the binary (and dll) name
+ var appName = Path.GetFileNameWithoutExtension(proj.Name);
+ foreach (var file in files) {
+ if (!string.IsNullOrEmpty(file.Extension))
+ continue;
+ if (files.Any(f => f.Extension == ".dll" && Path.GetFileNameWithoutExtension(f.Name) == file.Name)) {
+ Console.WriteLine($"Choosing app name {file.Name} from binary");
+ appName = file.Name;
+ break;
+ }
+ }
+
+ var app = dir.CreateSubdirectory($"{appName}.app");
var contents = app.CreateSubdirectory("Contents");
var resources = contents.CreateSubdirectory("Resources");
var macOs = contents.CreateSubdirectory("MacOS");
var resRegex = options.MacBundleResources.Select(GlobRegex).ToArray();
var ignoreRegex = options.MacBundleIgnore.Select(GlobRegex).ToArray();
- foreach (var file in dir.GetFiles()) {
+
+ foreach (var file in files) {
if (ignoreRegex.Any(r => r.IsMatch(file.Name)))
continue;
var destDir = resRegex.Any(r => r.IsMatch(file.Name)) ? resources : macOs;
@@ -131,8 +147,8 @@ namespace GameBundle {
destDir = app;
file.MoveTo(Path.Combine(destDir.FullName, file.Name), true);
}
- foreach (var sub in dir.GetDirectories()) {
- if (sub.Name == app.Name || ignoreRegex.Any(r => r.IsMatch(sub.Name)))
+ foreach (var sub in dirs) {
+ if (ignoreRegex.Any(r => r.IsMatch(sub.Name)))
continue;
var destDir = resRegex.Any(r => r.IsMatch(sub.Name)) ? resources : macOs;
var dest = new DirectoryInfo(Path.Combine(destDir.FullName, sub.Name));
@@ -140,6 +156,7 @@ namespace GameBundle {
dest.Delete(true);
sub.MoveTo(dest.FullName);
}
+ File.WriteAllText(Path.Combine(contents.FullName, "PkgInfo"), "APPL????");
}
private static Regex GlobRegex(string s) {
@@ -149,13 +166,9 @@ namespace GameBundle {
private static string GetBuildDir(Options options, FileInfo proj, string osName) {
var dir = Path.GetFullPath(options.OutputDirectory);
if (options.NameBuilds)
- return $"{dir}/{GetDisplayName(options, proj)}-{osName}";
+ return $"{dir}/{Path.GetFileNameWithoutExtension(proj.Name)}-{osName}";
return $"{dir}/{osName}";
}
- private static string GetDisplayName(Options options, FileInfo proj) {
- return string.IsNullOrEmpty(options.DisplayName) ? Path.GetFileNameWithoutExtension(proj.Name) : options.DisplayName;
- }
-
}
}
\ No newline at end of file
diff --git a/Test/Bundle.bat b/Test/Bundle.bat
index 8b44769..a7d645b 100644
--- a/Test/Bundle.bat
+++ b/Test/Bundle.bat
@@ -1 +1 @@
-"../GameBundle/bin/Debug/net5.0/GameBundle.exe" -wlm -bzn -s Test.csproj -o bin/Bundled -v -d "Test Project" --mac-bundle-ignore macmain.txt
\ No newline at end of file
+"../GameBundle/bin/Debug/net5.0/GameBundle.exe" -wlm -bzn -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt
\ No newline at end of file
diff --git a/Test/Test.csproj b/Test/Test.csproj
index e056db3..05c350f 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -5,6 +5,7 @@
net5.0
false
false
+ Test Project