mirror of
https://github.com/Ellpeck/GameBundle.git
synced 2024-11-22 08:43:28 +01:00
added the ability to exclude some files from the mac bundle
This commit is contained in:
parent
528607a755
commit
5ac15ed5b7
5 changed files with 12 additions and 5 deletions
|
@ -21,6 +21,8 @@ namespace GameBundle {
|
|||
public bool MacBundle { get; set; }
|
||||
[Option("mac-bundle-resources", Default = new[] {"Content", "*.icns"}, HelpText = "When creating an app bundle for mac, things that should go into the Resources folder rather than the MacOS folder")]
|
||||
public IEnumerable<string> MacBundleResources { get; set; }
|
||||
[Option("mac-bundle-ignore", Default = new string[0], HelpText = "When creating an app bundle for mac, things that should be left out of the mac bundle and stay in the output folder")]
|
||||
public IEnumerable<string> MacBundleIgnore { get; set; }
|
||||
[Option('z', "zip", HelpText = "Store the build results in zip files instead of folders")]
|
||||
public bool Zip { get; set; }
|
||||
[Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")]
|
||||
|
@ -35,7 +37,7 @@ 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 --name-builds and the app bundle instead of the project's name")]
|
||||
[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; }
|
||||
|
|
|
@ -68,9 +68,9 @@ namespace GameBundle {
|
|||
return publishResult;
|
||||
|
||||
// Run beauty
|
||||
var excludes = '"' + string.Join(";", options.ExcludedFiles) + '"';
|
||||
var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\"";
|
||||
var log = options.Verbose ? "Detail" : "Error";
|
||||
var beautyResult = RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True {path} {options.LibFolder} {excludes}", AppDomain.CurrentDomain.BaseDirectory);
|
||||
var beautyResult = RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True \"{path}\" \"{options.LibFolder}\" {excludes}", AppDomain.CurrentDomain.BaseDirectory);
|
||||
if (beautyResult != 0)
|
||||
return beautyResult;
|
||||
|
||||
|
@ -122,14 +122,17 @@ namespace GameBundle {
|
|||
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()) {
|
||||
if (ignoreRegex.Any(r => r.IsMatch(file.Name)))
|
||||
continue;
|
||||
var destDir = resRegex.Any(r => r.IsMatch(file.Name)) ? resources : macOs;
|
||||
if (file.Name.EndsWith("plist"))
|
||||
destDir = app;
|
||||
file.MoveTo(Path.Combine(destDir.FullName, file.Name), true);
|
||||
}
|
||||
foreach (var sub in dir.GetDirectories()) {
|
||||
if (sub.Name == app.Name)
|
||||
if (sub.Name == app.Name || 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));
|
||||
|
|
|
@ -1 +1 @@
|
|||
"../GameBundle/bin/Debug/net5.0/GameBundle.exe" -wlm -bzn -s Test.csproj -o bin/Bundled -v -d "Test Project"
|
||||
"../GameBundle/bin/Debug/net5.0/GameBundle.exe" -wlm -bzn -s Test.csproj -o bin/Bundled -v -d "Test Project" --mac-bundle-ignore macmain.txt
|
|
@ -17,5 +17,6 @@
|
|||
<ItemGroup>
|
||||
<MonoGameContentReference Include="Content\Content.mgcb" />
|
||||
<Content Include="Content\*\**" />
|
||||
<Content Include="macmain.txt" CopyToOutputDirectory="Always"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
1
Test/macmain.txt
Normal file
1
Test/macmain.txt
Normal file
|
@ -0,0 +1 @@
|
|||
This file should not be added to the mac bundle
|
Loading…
Reference in a new issue