mirror of
https://github.com/Ellpeck/GameBundle.git
synced 2024-11-22 16:48:34 +01:00
fixed mac app bundle by introducing PkgInfo and naming app properly
This commit is contained in:
parent
5ac15ed5b7
commit
64a56b25d4
4 changed files with 24 additions and 12 deletions
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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
|
||||
"../GameBundle/bin/Debug/net5.0/GameBundle.exe" -wlm -bzn -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt
|
|
@ -5,6 +5,7 @@
|
|||
<TargetFramework>net5.0</TargetFramework>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<TieredCompilation>false</TieredCompilation>
|
||||
<AssemblyName>Test Project</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue