From 6c9b179752bd047f322bf4db3757859c980ae11c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 31 Aug 2024 13:19:11 +0200 Subject: [PATCH] added monogame mode for excluding native libraries --- GameBundle/Options.cs | 4 +++- GameBundle/Program.cs | 10 ++++++---- README.md | 5 ++++- Test/Bundle.bat | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/GameBundle/Options.cs b/GameBundle/Options.cs index 55a10d7..6450f0b 100644 --- a/GameBundle/Options.cs +++ b/GameBundle/Options.cs @@ -52,6 +52,8 @@ public class Options { public bool SkipLib { get; set; } [Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")] public IEnumerable ExcludedFiles { get; set; } + [Option("mg", HelpText = "Exclude MonoGame's native libraries from being moved to the library folder, which is a requirement for DesktopGL version 3.8.2.1105 or later. This has the same behavior as supplying the --exclude arguments soft_oal.dll, SDL2.dll, libopenal.so.1, libSDL2-2.0.so.0, libopenal.1.dylib and libSDL2.dylib")] + public bool MonoGameExclusions { get; set; } [Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")] public string LibFolder { get; set; } @@ -68,4 +70,4 @@ public class Options { [Option('V', "include-version", HelpText = "Include the project's version in the names of the output directories")] public bool IncludeVersion { get; set; } -} \ No newline at end of file +} diff --git a/GameBundle/Program.cs b/GameBundle/Program.cs index a287be5..1b65deb 100644 --- a/GameBundle/Program.cs +++ b/GameBundle/Program.cs @@ -5,7 +5,6 @@ using System.IO; using System.IO.Compression; using System.IO.Enumeration; using System.Linq; -using System.Text.RegularExpressions; using CommandLine; namespace GameBundle; @@ -68,9 +67,12 @@ internal static class Program { // Run beauty if (!options.SkipLib && !config.SkipLib) { - var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\""; + var exclude = options.ExcludedFiles.ToList(); + if (options.MonoGameExclusions) + exclude.AddRange(["soft_oal.dll", "SDL2.dll", "libopenal.so.1", "libSDL2-2.0.so.0", "libopenal.1.dylib", "libSDL2.dylib"]); + var excludeString = exclude.Count > 0 ? $"\"{string.Join(";", exclude)}\"" : ""; var log = options.Verbose ? "Detail" : "Error"; - var beautyResult = Program.RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True --noflag=True \"{buildDir.FullName}\" \"{options.LibFolder}\" {excludes}", AppDomain.CurrentDomain.BaseDirectory); + var beautyResult = Program.RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True --noflag=True \"{buildDir.FullName}\" \"{options.LibFolder}\" {excludeString}", AppDomain.CurrentDomain.BaseDirectory); if (beautyResult != 0) return beautyResult; } @@ -237,4 +239,4 @@ internal static class Program { } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 697759e..0e7d2be 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ gamebundle -wlm GameBundle will then build a self-contained release of your application for each system using `dotnet publish` and clean up the output directory using [NetCoreBeauty](https://github.com/nulastudio/NetCoreBeauty) by moving most of the libraries into a `Lib` subdirectory. +## Building a MonoGame Project +If you're building a MonoGame project using MonoGame's DesktopGL version 3.8.2.1105 or later, you can additionally supply the `--mg` argument to automatically exclude MonoGame's native libraries from being moved into the `Lib` subdirectory, which is a requirement for your game to run. + # Configuring GameBundle takes several optional arguments to modify the way it works. To see a list of all possible arguments, simply run ``` @@ -27,4 +30,4 @@ gamebundle --help In the future, GameBundle plans to include the following features: - ~~An option to create a `.app` folder for Mac~~ Implemented in `1.1.1` - An option to create an installer for Windows -- An option to create a flatpak (or similar) installer for Linux \ No newline at end of file +- An option to create a flatpak (or similar) installer for Linux diff --git a/Test/Bundle.bat b/Test/Bundle.bat index a915405..15b90ab 100644 --- a/Test/Bundle.bat +++ b/Test/Bundle.bat @@ -1,3 +1,3 @@ dotnet build ../GameBundle/GameBundle.csproj rmdir /S /Q "bin/Bundled" -"../GameBundle/bin/Debug/net8.0/GameBundle.exe" -wlmWL -bnV -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt -N beta +"../GameBundle/bin/Debug/net8.0/GameBundle.exe" -wlmWL -bnV --mg -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt -N beta