added monogame mode for excluding native libraries

This commit is contained in:
Ell 2024-08-31 13:19:11 +02:00
parent a6600a1c84
commit 6c9b179752
4 changed files with 14 additions and 7 deletions

View file

@ -52,6 +52,8 @@ public class Options {
public bool SkipLib { get; set; } public bool SkipLib { get; set; }
[Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")] [Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")]
public IEnumerable<string> ExcludedFiles { get; set; } public IEnumerable<string> 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")] [Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")]
public string LibFolder { get; set; } public string LibFolder { get; set; }

View file

@ -5,7 +5,6 @@ using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.IO.Enumeration; using System.IO.Enumeration;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using CommandLine; using CommandLine;
namespace GameBundle; namespace GameBundle;
@ -68,9 +67,12 @@ internal static class Program {
// Run beauty // Run beauty
if (!options.SkipLib && !config.SkipLib) { 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 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) if (beautyResult != 0)
return beautyResult; return beautyResult;
} }

View file

@ -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. 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 # Configuring
GameBundle takes several optional arguments to modify the way it works. To see a list of all possible arguments, simply run GameBundle takes several optional arguments to modify the way it works. To see a list of all possible arguments, simply run
``` ```

View file

@ -1,3 +1,3 @@
dotnet build ../GameBundle/GameBundle.csproj dotnet build ../GameBundle/GameBundle.csproj
rmdir /S /Q "bin/Bundled" 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