Compare commits

..

No commits in common. "db1a53291e1b06240ec7c475388c193e46e22e15" and "3fd8f41b351fb869c137febaf6a2ce038a3bca3d" have entirely different histories.

8 changed files with 279 additions and 313 deletions

View file

@ -1,12 +1,12 @@
{ {
"version": 1, "version": 1,
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"nulastudio.ncbeauty": { "nulastudio.ncbeauty": {
"version": "1.2.9.3", "version": "1.2.9.3",
"commands": [ "commands": [
"ncbeauty" "ncbeauty"
] ]
}
} }
}
} }

View file

@ -14,7 +14,7 @@
<PackageIcon>Logo.png</PackageIcon> <PackageIcon>Logo.png</PackageIcon>
<PackAsTool>true</PackAsTool> <PackAsTool>true</PackAsTool>
<ToolCommandName>gamebundle</ToolCommandName> <ToolCommandName>gamebundle</ToolCommandName>
<VersionPrefix>1.5.2</VersionPrefix> <VersionPrefix>1.5.0</VersionPrefix>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -2,70 +2,66 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using CommandLine; using CommandLine;
namespace GameBundle; namespace GameBundle {
public class Options {
public class Options { [Option('s', "source", HelpText = "The location of the .csproj file that should be built and bundled. By default, the current directory is scanned for one")]
public string SourceFile { get; set; }
[Option('o', "output", Default = "bin/Bundled", HelpText = "The location of the directory that the bundles should be stored in")]
public string OutputDirectory { get; set; }
[Option('v', "verbose", HelpText = "Display verbose output while building")]
public bool Verbose { get; set; }
[Option('s', "source", HelpText = "The location of the .csproj file that should be built and bundled. By default, the current directory is scanned for one")] [Option('w', "win", HelpText = "Bundle for windows")]
public string SourceFile { get; set; } public bool BuildWindows { get; set; }
[Option('o', "output", Default = "bin/Bundled", HelpText = "The location of the directory that the bundles should be stored in")] [Option('l', "linux", HelpText = "Bundle for linux")]
public string OutputDirectory { get; set; } public bool BuildLinux { get; set; }
[Option('v', "verbose", HelpText = "Display verbose output while building")] [Option('m', "mac", HelpText = "Bundle for mac")]
public bool Verbose { get; set; } public bool BuildMac { get; set; }
[Option("win-rid", Default = "win-x64", HelpText = "The RID to use for windows builds")]
public string WindowsRid { get; set; }
[Option("linux-rid", Default = "linux-x64", HelpText = "The RID to use for linux builds")]
public string LinuxRid { get; set; }
[Option("mac-rid", Default = "osx-x64", HelpText = "The RID to use for mac builds")]
public string MacRid { get; set; }
[Option('w', "win", HelpText = "Bundle for windows")] [Option('W', "win-arm", HelpText = "Bundle for windows arm")]
public bool BuildWindows { get; set; } public bool BuildWindowsArm { get; set; }
[Option('l', "linux", HelpText = "Bundle for linux")] [Option('L', "linux-arm", HelpText = "Bundle for linux arm")]
public bool BuildLinux { get; set; } public bool BuildLinuxArm { get; set; }
[Option('m', "mac", HelpText = "Bundle for mac")] [Option('M', "mac-arm", HelpText = "Bundle for mac arm")]
public bool BuildMac { get; set; } public bool BuildMacArm { get; set; }
[Option("win-rid", Default = "win-x64", HelpText = "The RID to use for windows builds")] [Option("win-arm-rid", Default = "win-arm64", HelpText = "The RID to use for windows arm builds")]
public string WindowsRid { get; set; } public string WindowsArmRid { get; set; }
[Option("linux-rid", Default = "linux-x64", HelpText = "The RID to use for linux builds")] [Option("linux-arm-rid", Default = "linux-arm64", HelpText = "The RID to use for linux arm builds")]
public string LinuxRid { get; set; } public string LinuxArmRid { get; set; }
[Option("mac-rid", Default = "osx-x64", HelpText = "The RID to use for mac builds")] [Option("mac-arm-rid", Default = "osx-arm64", HelpText = "The RID to use for mac arm builds")]
public string MacRid { get; set; } public string MacArmRid { get; set; }
[Option('W', "win-arm", HelpText = "Bundle for windows arm")] [Option('z', "zip", HelpText = "Store the build results in zip files instead of folders")]
public bool BuildWindowsArm { get; set; } public bool Zip { get; set; }
[Option('L', "linux-arm", HelpText = "Bundle for linux arm")] [Option('b', "mac-bundle", HelpText = "Create an app bundle for mac")]
public bool BuildLinuxArm { get; set; } public bool MacBundle { get; set; }
[Option('M', "mac-arm", HelpText = "Bundle for mac arm")] [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 bool BuildMacArm { get; set; } public IEnumerable<string> MacBundleResources { get; set; }
[Option("win-arm-rid", Default = "win-arm64", HelpText = "The RID to use for windows arm builds")] [Option("mac-bundle-ignore", 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 string WindowsArmRid { get; set; } public IEnumerable<string> MacBundleIgnore { get; set; }
[Option("linux-arm-rid", Default = "linux-arm64", HelpText = "The RID to use for linux arm builds")]
public string LinuxArmRid { get; set; }
[Option("mac-arm-rid", Default = "osx-arm64", HelpText = "The RID to use for mac arm builds")]
public string MacArmRid { get; set; }
[Option('z', "zip", HelpText = "Store the build results in zip files instead of folders")] [Option("skip-lib", HelpText = "When bundling, skip beautifying the output by moving files to the library folder")]
public bool Zip { get; set; } public bool SkipLib { get; set; }
[Option('b', "mac-bundle", HelpText = "Create an app bundle for mac")] [Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")]
public bool MacBundle { get; set; } public IEnumerable<string> ExcludedFiles { 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")] [Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")]
public IEnumerable<string> MacBundleResources { get; set; } public string LibFolder { get; set; }
[Option("mac-bundle-ignore", 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("skip-lib", HelpText = "When bundling, skip beautifying the output by moving files to the library folder")] [Option('t', "trim", HelpText = "Trim the application when publishing")]
public bool SkipLib { get; set; } public bool Trim { get; set; }
[Option('e', "exclude", HelpText = "Files that should not be moved to the library folder")] [Option('c', "config", Default = "Release", HelpText = "The build configuration to use")]
public IEnumerable<string> ExcludedFiles { get; set; } public string BuildConfig { get; set; }
[Option("lib-name", Default = "Lib", HelpText = "The name of the library folder that is created")] [Option('a', "build-args", HelpText = "Additional arguments that should be passed to the dotnet publish command")]
public string LibFolder { get; set; } public string BuildArgs { get; set; }
[Option('n', "name-builds", HelpText = "Name the build output directories by the name of the executable")]
[Option('t', "trim", HelpText = "Trim the application when publishing")] public bool NameBuilds { get; set; }
public bool Trim { get; set; }
[Option('c', "config", Default = "Release", HelpText = "The build configuration to use")]
public string BuildConfig { get; set; }
[Option('a', "build-args", HelpText = "Additional arguments that should be passed to the dotnet publish command")]
public string BuildArgs { get; set; }
[Option('n', "name-builds", HelpText = "Name the build output directories by the name of the executable")]
public bool NameBuilds { get; set; }
[Option('N', "name-addition", HelpText = "An additional string of text that should be included in the names of the output directories")]
public string NameAddition { get; set; }
[Option('V', "include-version", HelpText = "Include the project's version in the names of the output directories")]
public bool IncludeVersion { get; set; }
}
} }

View file

@ -7,239 +7,211 @@ using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using CommandLine; using CommandLine;
namespace GameBundle; namespace GameBundle {
internal static class Program {
internal static class Program { private static int Main(string[] args) {
return new Parser(c => {
private static int Main(string[] args) { c.HelpWriter = Console.Error;
return new Parser(c => { c.EnableDashDash = true;
c.HelpWriter = Console.Error; }).ParseArguments<Options>(args).MapResult(Run, _ => -1);
c.EnableDashDash = true;
}).ParseArguments<Options>(args).MapResult(Program.Run, _ => -1);
}
private static int Run(Options options) {
// make sure all of the required tools are installed
if (Program.RunProcess(options, "dotnet", "tool restore", AppDomain.CurrentDomain.BaseDirectory) != 0) {
Console.WriteLine("dotnet tool restore failed, aborting");
return -1;
} }
var proj = Program.GetProjectFile(options); private static int Run(Options options) {
if (proj == null || !proj.Exists) { // make sure all of the required tools are installed
Console.WriteLine("Project file not found, aborting"); if (RunProcess(options, "dotnet", "tool restore", AppDomain.CurrentDomain.BaseDirectory) != 0) {
return -1; Console.WriteLine("dotnet tool restore failed, aborting");
}
Console.WriteLine($"Bundling project {proj.FullName}");
var builtAnything = false;
var toBuild = new List<BuildConfig> {
// regular builds
new("windows", "win", options.WindowsRid, options.BuildWindows),
new("linux", "linux", options.LinuxRid, options.BuildLinux),
new("mac", "mac", options.MacRid, options.BuildMac, false, d => options.MacBundle ? Program.CreateMacBundle(options, d) : 0),
// arm builds
new("windows arm", "win-arm", options.WindowsArmRid, options.BuildWindowsArm, true),
new("linux arm", "linux-arm", options.LinuxArmRid, options.BuildLinuxArm, true),
new("mac arm", "mac-arm", options.MacArmRid, options.BuildMacArm, true, d => options.MacBundle ? Program.CreateMacBundle(options, d) : 0)
};
foreach (var config in toBuild) {
if (config.ShouldBuild) {
Console.WriteLine($"Bundling for {config.DisplayName}");
var res = Program.Publish(options, proj, config);
if (res != 0)
return res;
builtAnything = true;
}
}
if (!builtAnything)
Console.WriteLine("No build took place. Supply -w, -l or -m arguments or see available arguments using --help.");
Console.WriteLine("Done");
return 0;
}
private static int Publish(Options options, FileInfo proj, BuildConfig config) {
var buildDir = Program.GetBuildDir(options, config.DirectoryName);
var publishResult = Program.RunProcess(options, "dotnet", $"publish \"{proj.FullName}\" -o \"{buildDir.FullName}\" -r {config.Rid} --self-contained -c {options.BuildConfig} /p:PublishTrimmed={options.Trim} {options.BuildArgs}");
if (publishResult != 0)
return publishResult;
// Run beauty
if (!options.SkipLib && !config.SkipLib) {
var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\"";
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);
if (beautyResult != 0)
return beautyResult;
}
// Add version if named builds are enabled
if (options.IncludeVersion) {
var version = Program.GetBuildVersion(buildDir);
if (version == null) {
Console.WriteLine("Couldn't determine build version, aborting");
return -1; return -1;
} }
var dest = Path.Combine(buildDir.Parent.FullName, $"{version}-{buildDir.Name}");
Program.MoveDirectory(options, buildDir, dest);
}
// Rename build folder if named builds are enabled var proj = GetProjectFile(options);
if (options.NameBuilds) { if (proj == null || !proj.Exists) {
var name = Program.GetBuildName(buildDir); Console.WriteLine("Project file not found, aborting");
if (name == null) {
Console.WriteLine("Couldn't determine build name, aborting");
return -1; return -1;
} }
var dest = Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}"); Console.WriteLine($"Bundling project {proj.FullName}");
Program.MoveDirectory(options, buildDir, dest);
var builtAnything = false;
var toBuild = new List<BuildConfig> {
// regular builds
new("windows", "win", options.WindowsRid, options.BuildWindows),
new("linux", "linux", options.LinuxRid, options.BuildLinux),
new("mac", "mac", options.MacRid, options.BuildMac, false, d => options.MacBundle ? CreateMacBundle(options, d) : 0),
// arm builds
new("windows arm", "win-arm", options.WindowsArmRid, options.BuildWindowsArm, true),
new("linux arm", "linux-arm", options.LinuxArmRid, options.BuildLinuxArm, true),
new("mac arm", "mac-arm", options.MacArmRid, options.BuildMacArm, true, d => options.MacBundle ? CreateMacBundle(options, d) : 0)
};
foreach (var config in toBuild) {
if (config.ShouldBuild) {
Console.WriteLine($"Bundling for {config.DisplayName}");
var res = Publish(options, proj, config);
if (res != 0)
return res;
builtAnything = true;
}
}
if (!builtAnything)
Console.WriteLine("No build took place. Supply -w, -l or -m arguments or see available arguments using --help.");
Console.WriteLine("Done");
return 0;
} }
// Run any additional actions like creating the mac bundle private static int Publish(Options options, FileInfo proj, BuildConfig config) {
if (config.AdditionalAction != null) { var buildDir = GetBuildDir(options, config.DirectoryName);
var result = config.AdditionalAction.Invoke(buildDir); var publishResult = RunProcess(options, "dotnet", $"publish \"{proj.FullName}\" -o \"{buildDir.FullName}\" -r {config.Rid} --self-contained -c {options.BuildConfig} /p:PublishTrimmed={options.Trim} {options.BuildArgs}");
if (result != 0) if (publishResult != 0)
return result; return publishResult;
// Run beauty
if (!options.SkipLib && !config.SkipLib) {
var excludes = $"\"{string.Join(";", options.ExcludedFiles)}\"";
var log = options.Verbose ? "Detail" : "Error";
var beautyResult = RunProcess(options, "dotnet", $"ncbeauty --loglevel={log} --force=True --noflag=True \"{buildDir.FullName}\" \"{options.LibFolder}\" {excludes}", AppDomain.CurrentDomain.BaseDirectory);
if (beautyResult != 0)
return beautyResult;
}
// Rename build folder if named builds are enabled
if (options.NameBuilds) {
var name = GetBuildName(options, buildDir);
if (name == null) {
Console.WriteLine("Couldn't determine build name, aborting");
return -1;
}
var dest = Path.Combine(buildDir.Parent.FullName, $"{name}-{buildDir.Name}");
if (Directory.Exists(dest))
Directory.Delete(dest, true);
buildDir.MoveTo(dest);
if (options.Verbose)
Console.WriteLine($"Moved build directory to {buildDir.FullName}");
}
// Run any additional actions like creating the mac bundle
if (config.AdditionalAction != null) {
var result = config.AdditionalAction.Invoke(buildDir);
if (result != 0)
return result;
}
// Zip the output if required
if (options.Zip) {
var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip");
if (File.Exists(zipLocation))
File.Delete(zipLocation);
ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true);
buildDir.Delete(true);
if (options.Verbose)
Console.WriteLine($"Zipped build to {zipLocation}");
}
return 0;
} }
// Zip the output if required private static int RunProcess(Options options, string program, string args, string workingDir = "") {
if (options.Zip) {
var zipLocation = Path.Combine(buildDir.Parent.FullName, $"{buildDir.Name}.zip");
if (File.Exists(zipLocation))
File.Delete(zipLocation);
ZipFile.CreateFromDirectory(buildDir.FullName, zipLocation, CompressionLevel.Optimal, true);
buildDir.Delete(true);
if (options.Verbose) if (options.Verbose)
Console.WriteLine($"Zipped build to {zipLocation}"); Console.WriteLine($"> {program} {args}");
} var info = new ProcessStartInfo(program, args) {WorkingDirectory = workingDir};
return 0; if (!options.Verbose)
} info.CreateNoWindow = true;
var process = Process.Start(info);
private static int RunProcess(Options options, string program, string args, string workingDir = "") { process.WaitForExit();
if (options.Verbose)
Console.WriteLine($"> {program} {args}");
var info = new ProcessStartInfo(program, args) {WorkingDirectory = workingDir};
if (!options.Verbose)
info.CreateNoWindow = true;
var process = Process.Start(info);
process.WaitForExit();
if (options.Verbose)
Console.WriteLine($"{program} finished with exit code {process.ExitCode}");
return process.ExitCode;
}
private static FileInfo GetProjectFile(Options options) {
if (!string.IsNullOrEmpty(options.SourceFile))
return new FileInfo(options.SourceFile);
var dir = new DirectoryInfo(".");
foreach (var file in dir.EnumerateFiles()) {
if (Path.GetExtension(file.FullName).Contains("proj"))
return file;
}
return null;
}
private static int CreateMacBundle(Options options, DirectoryInfo buildDir) {
var buildName = Program.GetBuildName(buildDir);
var app = buildDir.CreateSubdirectory($"{buildName}.app");
var contents = app.CreateSubdirectory("Contents");
var resources = contents.CreateSubdirectory("Resources");
var macOs = contents.CreateSubdirectory("MacOS");
var resRegex = options.MacBundleResources.Select(Program.GlobRegex).ToArray();
var ignoreRegex = options.MacBundleIgnore.Select(Program.GlobRegex).ToArray();
if (options.Verbose)
Console.WriteLine($"Creating app bundle {app}");
foreach (var file in buildDir.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") || file.Name == "PkgInfo")
destDir = contents;
file.MoveTo(Path.Combine(destDir.FullName, file.Name), true);
}
foreach (var sub in buildDir.GetDirectories()) {
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));
if (dest.Exists)
dest.Delete(true);
sub.MoveTo(dest.FullName);
}
var info = Path.Combine(contents.FullName, "PkgInfo");
if (!File.Exists(info)) {
File.WriteAllText(info, "APPL????");
if (options.Verbose) if (options.Verbose)
Console.WriteLine($"Creating package info at {info}"); Console.WriteLine($"{program} finished with exit code {process.ExitCode}");
return process.ExitCode;
} }
return 0; private static FileInfo GetProjectFile(Options options) {
} if (!string.IsNullOrEmpty(options.SourceFile))
return new FileInfo(options.SourceFile);
private static Regex GlobRegex(string s) { var dir = new DirectoryInfo(".");
return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".")); foreach (var file in dir.EnumerateFiles()) {
} if (Path.GetExtension(file.FullName).Contains("proj"))
return file;
private static DirectoryInfo GetBuildDir(Options options, string name) { }
if (options.NameAddition != null)
name = $"{options.NameAddition}-{name}";
return new DirectoryInfo(Path.Combine(Path.GetFullPath(options.OutputDirectory), name));
}
private static string GetBuildName(DirectoryInfo buildDir) {
return Path.GetFileNameWithoutExtension(Program.GetAssemblyFile(buildDir)?.Name);
}
private static string GetBuildVersion(DirectoryInfo buildDir) {
var assemblyFile = Program.GetAssemblyFile(buildDir);
if (assemblyFile == null)
return null; return null;
var version = FileVersionInfo.GetVersionInfo(assemblyFile.FullName);
return version.ProductVersion;
}
private static FileInfo GetAssemblyFile(DirectoryInfo buildDir) {
var files = buildDir.GetFiles();
foreach (var file in files) {
if (file.Extension != ".dll")
continue;
// the assembly is (most likely) the dll file that has a matching binary or exe file in the same location
if (files.Any(f => f.Extension is ".exe" or "" && Path.GetFileNameWithoutExtension(f.Name) == Path.GetFileNameWithoutExtension(file.Name)))
return file;
} }
return null;
}
private static void MoveDirectory(Options options, DirectoryInfo dir, string dest) { private static int CreateMacBundle(Options options, DirectoryInfo buildDir) {
if (Directory.Exists(dest)) var buildName = GetBuildName(options, buildDir);
Directory.Delete(dest, true); var app = buildDir.CreateSubdirectory($"{buildName}.app");
dir.MoveTo(dest!); var contents = app.CreateSubdirectory("Contents");
if (options.Verbose) var resources = contents.CreateSubdirectory("Resources");
Console.WriteLine($"Moved build directory to {dir.FullName}"); var macOs = contents.CreateSubdirectory("MacOS");
} var resRegex = options.MacBundleResources.Select(GlobRegex).ToArray();
var ignoreRegex = options.MacBundleIgnore.Select(GlobRegex).ToArray();
private readonly struct BuildConfig { if (options.Verbose)
Console.WriteLine($"Creating app bundle {app}");
public readonly string DisplayName; foreach (var file in buildDir.GetFiles()) {
public readonly string DirectoryName; if (ignoreRegex.Any(r => r.IsMatch(file.Name)))
public readonly string Rid; continue;
public readonly bool ShouldBuild; var destDir = resRegex.Any(r => r.IsMatch(file.Name)) ? resources : macOs;
public readonly bool SkipLib; if (file.Name.EndsWith("plist") || file.Name == "PkgInfo")
public readonly Func<DirectoryInfo, int> AdditionalAction; destDir = contents;
file.MoveTo(Path.Combine(destDir.FullName, file.Name), true);
}
foreach (var sub in buildDir.GetDirectories()) {
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));
if (dest.Exists)
dest.Delete(true);
sub.MoveTo(dest.FullName);
}
var info = Path.Combine(contents.FullName, "PkgInfo");
if (!File.Exists(info)) {
File.WriteAllText(info, "APPL????");
if (options.Verbose)
Console.WriteLine($"Creating package info at {info}");
}
return 0;
}
private static Regex GlobRegex(string s) {
return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", "."));
}
private static DirectoryInfo GetBuildDir(Options options, string osName) {
return new DirectoryInfo(Path.Combine(Path.GetFullPath(options.OutputDirectory), osName));
}
private static string GetBuildName(Options options, DirectoryInfo buildDir) {
// determine build name based on the names of the exe or binary that have a matching dll file
var files = buildDir.GetFiles();
foreach (var file in files) {
if (file.Extension != ".exe" && file.Extension != string.Empty)
continue;
var name = Path.GetFileNameWithoutExtension(file.Name);
if (files.Any(f => f.Extension == ".dll" && Path.GetFileNameWithoutExtension(f.Name) == name))
return name;
}
return null;
}
private readonly struct BuildConfig {
public readonly string DisplayName;
public readonly string DirectoryName;
public readonly string Rid;
public readonly bool ShouldBuild;
public readonly bool SkipLib;
public readonly Func<DirectoryInfo, int> AdditionalAction;
public BuildConfig(string displayName, string directoryName, string rid, bool shouldBuild, bool skipLib = false, Func<DirectoryInfo, int> additionalAction = null) {
this.DisplayName = displayName;
this.DirectoryName = directoryName;
this.Rid = rid;
this.ShouldBuild = shouldBuild;
this.SkipLib = skipLib;
this.AdditionalAction = additionalAction;
}
public BuildConfig(string displayName, string directoryName, string rid, bool shouldBuild, bool skipLib = false, Func<DirectoryInfo, int> additionalAction = null) {
this.DisplayName = displayName;
this.DirectoryName = directoryName;
this.Rid = rid;
this.ShouldBuild = shouldBuild;
this.SkipLib = skipLib;
this.AdditionalAction = additionalAction;
} }
} }
} }

View file

@ -1,2 +1 @@
rmdir /S /Q "bin/Bundled" "../GameBundle/bin/Debug/net6.0/GameBundle.exe" -wlmWL -bzn -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt
"../GameBundle/bin/Debug/net6.0/GameBundle.exe" -wlmWL -bznV -s Test.csproj -o bin/Bundled -v --mac-bundle-ignore macmain.txt -N beta

View file

@ -2,28 +2,28 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using MLEM.Startup; using MLEM.Startup;
namespace Test; namespace Test {
public class GameImpl : MlemGame {
public class GameImpl : MlemGame { public static GameImpl Instance { get; private set; }
private Texture2D texture;
public static GameImpl Instance { get; private set; } public GameImpl() {
private Texture2D texture; Instance = this;
}
protected override void LoadContent() {
base.LoadContent();
this.texture = LoadContent<Texture2D>("Textures/Test");
}
protected override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.Black);
base.DoDraw(gameTime);
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10));
this.SpriteBatch.Draw(this.texture, Vector2.Zero, Color.White);
this.SpriteBatch.End();
}
public GameImpl() {
GameImpl.Instance = this;
} }
protected override void LoadContent() {
base.LoadContent();
this.texture = MlemGame.LoadContent<Texture2D>("Textures/Test");
}
protected override void DoDraw(GameTime gameTime) {
this.GraphicsDevice.Clear(Color.Black);
base.DoDraw(gameTime);
this.SpriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Matrix.CreateScale(10));
this.SpriteBatch.Draw(this.texture, Vector2.Zero, Color.White);
this.SpriteBatch.End();
}
} }

View file

@ -1,14 +1,14 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using MLEM.Misc; using MLEM.Misc;
namespace Test; namespace Test {
public static class Program {
public static class Program { public static void Main() {
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
using var game = new GameImpl();
game.Run();
}
public static void Main() {
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
using var game = new GameImpl();
game.Run();
} }
} }

View file

@ -1,24 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<PublishReadyToRun>false</PublishReadyToRun> <PublishReadyToRun>false</PublishReadyToRun>
<TieredCompilation>false</TieredCompilation> <TieredCompilation>false</TieredCompilation>
<AssemblyName>Test Project</AssemblyName> <AssemblyName>Test Project</AssemblyName>
<Version>1.2.3</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Contentless" Version="2.0.*" /> <PackageReference Include="Contentless" Version="2.0.*" />
<PackageReference Include="MLEM.Startup" Version="3.2.*" /> <PackageReference Include="MLEM.Startup" Version="3.2.*" />
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.*" /> <PackageReference Include="MonoGame.Content.Builder" Version="3.7.*" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" /> <PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" /> <MonoGameContentReference Include="Content\Content.mgcb" />
<Content Include="Content\*\**" /> <Content Include="Content\*\**" />
<Content Include="macmain.txt" CopyToOutputDirectory="Always" /> <Content Include="macmain.txt" CopyToOutputDirectory="Always"/>
</ItemGroup> </ItemGroup>
</Project> </Project>