From 9181f4a1f341943c0003b18100af8af2cff9bfce Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:39:09 -0500 Subject: [PATCH 01/34] Use Directory.Build.targets Moved common csproj properties for NuGet into Directory.Build.targets --- Directory.Build.targets | 8 ++++++++ .../MonoGame.Extended.Animations.csproj | 5 +---- .../MonoGame.Extended.Collisions.csproj | 5 +---- .../MonoGame.Extended.Content.Pipeline.csproj | 5 +---- .../MonoGame.Extended.Entities.csproj | 5 +---- .../MonoGame.Extended.Graphics.csproj | 5 +---- src/cs/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj | 5 +---- .../MonoGame.Extended.Input.csproj | 5 +---- .../MonoGame.Extended.Particles.csproj | 5 +---- .../MonoGame.Extended.Tiled.csproj | 5 +---- .../MonoGame.Extended.Tweening.csproj | 5 +---- src/cs/MonoGame.Extended/MonoGame.Extended.csproj | 7 ++----- 12 files changed, 20 insertions(+), 45 deletions(-) create mode 100644 Directory.Build.targets diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 000000000..10ee6ccd8 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,8 @@ + + + craftworkgames + https://github.com/craftworkgames/MonoGame.Extended + https://github.com/craftworkgames/MonoGame.Extended + https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png + + diff --git a/src/cs/MonoGame.Extended.Animations/MonoGame.Extended.Animations.csproj b/src/cs/MonoGame.Extended.Animations/MonoGame.Extended.Animations.csproj index 4cde0df1f..628358571 100644 --- a/src/cs/MonoGame.Extended.Animations/MonoGame.Extended.Animations.csproj +++ b/src/cs/MonoGame.Extended.Animations/MonoGame.Extended.Animations.csproj @@ -7,9 +7,6 @@ craftworkgames Animations to make MonoGame more awesome. monogame animations spritesheet sprite - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png @@ -24,4 +21,4 @@ - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Collisions/MonoGame.Extended.Collisions.csproj b/src/cs/MonoGame.Extended.Collisions/MonoGame.Extended.Collisions.csproj index 2c28c9c71..3585e6bc2 100644 --- a/src/cs/MonoGame.Extended.Collisions/MonoGame.Extended.Collisions.csproj +++ b/src/cs/MonoGame.Extended.Collisions/MonoGame.Extended.Collisions.csproj @@ -7,9 +7,6 @@ craftworkgames Collisions to make MonoGame more awesome. monogame collisions - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -26,4 +23,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj b/src/cs/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj index a2d6ae9cb..264c34eb4 100644 --- a/src/cs/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj +++ b/src/cs/MonoGame.Extended.Content.Pipeline/MonoGame.Extended.Content.Pipeline.csproj @@ -12,9 +12,6 @@ craftworkgames Content Pipeline importers and processors to make MonoGame more awesome. monogame content importer processor reader tiled texturepacker bmfont animations - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png @@ -45,4 +42,4 @@ Always - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj b/src/cs/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj index 4d5ce7c10..8430d91fa 100644 --- a/src/cs/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj +++ b/src/cs/MonoGame.Extended.Entities/MonoGame.Extended.Entities.csproj @@ -7,9 +7,6 @@ craftworkgames An Entity Component System to make MonoGame more awesome. monogame ecs entity component system - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png @@ -25,4 +22,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Graphics/MonoGame.Extended.Graphics.csproj b/src/cs/MonoGame.Extended.Graphics/MonoGame.Extended.Graphics.csproj index c6fb9bbd0..8553742b6 100644 --- a/src/cs/MonoGame.Extended.Graphics/MonoGame.Extended.Graphics.csproj +++ b/src/cs/MonoGame.Extended.Graphics/MonoGame.Extended.Graphics.csproj @@ -7,9 +7,6 @@ craftworkgames Graphics makes MonoGame more awesome. monogame graphics batcher effects - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -46,4 +43,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj b/src/cs/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj index e83648641..d0baf7323 100644 --- a/src/cs/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj +++ b/src/cs/MonoGame.Extended.Gui/MonoGame.Extended.Gui.csproj @@ -7,9 +7,6 @@ craftworkgames A GUI system for MonoGame written from the ground up to make MonoGame more awesome. monogame gui - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -27,4 +24,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Input/MonoGame.Extended.Input.csproj b/src/cs/MonoGame.Extended.Input/MonoGame.Extended.Input.csproj index 3c69c1afa..67df5b445 100644 --- a/src/cs/MonoGame.Extended.Input/MonoGame.Extended.Input.csproj +++ b/src/cs/MonoGame.Extended.Input/MonoGame.Extended.Input.csproj @@ -7,9 +7,6 @@ craftworkgames An event based input system to MonoGame more awesome. monogame input event based listeners - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -26,4 +23,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Particles/MonoGame.Extended.Particles.csproj b/src/cs/MonoGame.Extended.Particles/MonoGame.Extended.Particles.csproj index a39b6ab20..48de187c0 100644 --- a/src/cs/MonoGame.Extended.Particles/MonoGame.Extended.Particles.csproj +++ b/src/cs/MonoGame.Extended.Particles/MonoGame.Extended.Particles.csproj @@ -7,9 +7,6 @@ craftworkgames A high performance particle system to make MonoGame more awesome. monogame particle system - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -30,4 +27,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Tiled/MonoGame.Extended.Tiled.csproj b/src/cs/MonoGame.Extended.Tiled/MonoGame.Extended.Tiled.csproj index ece0263b9..fe87c77e3 100644 --- a/src/cs/MonoGame.Extended.Tiled/MonoGame.Extended.Tiled.csproj +++ b/src/cs/MonoGame.Extended.Tiled/MonoGame.Extended.Tiled.csproj @@ -7,9 +7,6 @@ craftworkgames Support for Tiled maps to make MonoGame more awesome. See http://www.mapeditor.org monogame tiled maps orthographic isometric - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png @@ -30,4 +27,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended.Tweening/MonoGame.Extended.Tweening.csproj b/src/cs/MonoGame.Extended.Tweening/MonoGame.Extended.Tweening.csproj index b0c9c6531..434349bc2 100644 --- a/src/cs/MonoGame.Extended.Tweening/MonoGame.Extended.Tweening.csproj +++ b/src/cs/MonoGame.Extended.Tweening/MonoGame.Extended.Tweening.csproj @@ -7,9 +7,6 @@ craftworkgames A tweening system to make MonoGame more awesome. monogame animations tweening - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png @@ -25,4 +22,4 @@ All - \ No newline at end of file + diff --git a/src/cs/MonoGame.Extended/MonoGame.Extended.csproj b/src/cs/MonoGame.Extended/MonoGame.Extended.csproj index c63b9025b..52dccbb30 100644 --- a/src/cs/MonoGame.Extended/MonoGame.Extended.csproj +++ b/src/cs/MonoGame.Extended/MonoGame.Extended.csproj @@ -7,9 +7,6 @@ craftworkgames It makes MonoGame more awesome. monogame extended pipeline bmfont tiled texture atlas input viewport fps shapes sprite - https://github.com/craftworkgames/MonoGame.Extended - https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png true @@ -26,5 +23,5 @@ - - \ No newline at end of file + + From 9c1af60e6f6e887c50229b19974992fd674093d8 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:40:08 -0500 Subject: [PATCH 02/34] Added version tag This is so we don't have to rely on github runner actions to generate the version number, and we can use it in the build scripts --- Directory.Build.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 10ee6ccd8..8d177d693 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,6 @@ + 3.9.0 craftworkgames https://github.com/craftworkgames/MonoGame.Extended https://github.com/craftworkgames/MonoGame.Extended From e3e6861f44c3ae11084538c8b49c4adbd8907e9a Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:41:07 -0500 Subject: [PATCH 03/34] PackageIconUrl is deprecated NuGet packages should use PacakgeIcon with a packed image inside the NuGet insetad of PackageIconUrl --- Directory.Build.targets | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 8d177d693..33ec7e443 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -4,6 +4,11 @@ craftworkgames https://github.com/craftworkgames/MonoGame.Extended https://github.com/craftworkgames/MonoGame.Extended - https://raw.githubusercontent.com/craftworkgames/MonoGame.Extended/master/Logos/logo-nuget-128.png + logo-nuget-128.png + + + + + From cd728fde97cc5d2bf3536a7ee8fa9b4e3b1ddb77 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:42:44 -0500 Subject: [PATCH 04/34] Pack README.md in NuGet packages --- Directory.Build.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 33ec7e443..25931dee8 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -5,10 +5,12 @@ https://github.com/craftworkgames/MonoGame.Extended https://github.com/craftworkgames/MonoGame.Extended logo-nuget-128.png + README.md + From d3536f4470bccc4d72e8aab6c0b3c1b3852e6afd Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:43:25 -0500 Subject: [PATCH 05/34] Add common tags for NuGet packages Added the ``, ``, `` and `` tags --- Directory.Build.targets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 25931dee8..a3d7b9d4e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -4,8 +4,12 @@ craftworkgames https://github.com/craftworkgames/MonoGame.Extended https://github.com/craftworkgames/MonoGame.Extended + git + develop + en logo-nuget-128.png README.md + MIT From 7e3a4a97bd205aa2c00677c9cc769036847ce568 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:45:19 -0500 Subject: [PATCH 06/34] Added new Cake Frosting project --- build/Build.csproj | 10 ++++++++ build/Program.cs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 build/Build.csproj create mode 100644 build/Program.cs diff --git a/build/Build.csproj b/build/Build.csproj new file mode 100644 index 000000000..064f3a4c1 --- /dev/null +++ b/build/Build.csproj @@ -0,0 +1,10 @@ + + + Exe + net7.0 + $(MSBuildProjectDirectory) + + + + + \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs new file mode 100644 index 000000000..fb088c628 --- /dev/null +++ b/build/Program.cs @@ -0,0 +1,57 @@ +using System.Threading.Tasks; +using Cake.Core; +using Cake.Core.Diagnostics; +using Cake.Frosting; + +public static class Program +{ + public static int Main(string[] args) + { + return new CakeHost() + .UseContext() + .Run(args); + } +} + +public class BuildContext : FrostingContext +{ + public bool Delay { get; set; } + + public BuildContext(ICakeContext context) + : base(context) + { + Delay = context.Arguments.HasArgument("delay"); + } +} + +[TaskName("Hello")] +public sealed class HelloTask : FrostingTask +{ + public override void Run(BuildContext context) + { + context.Log.Information("Hello"); + } +} + +[TaskName("World")] +[IsDependentOn(typeof(HelloTask))] +public sealed class WorldTask : AsyncFrostingTask +{ + // Tasks can be asynchronous + public override async Task RunAsync(BuildContext context) + { + if (context.Delay) + { + context.Log.Information("Waiting..."); + await Task.Delay(1500); + } + + context.Log.Information("World"); + } +} + +[TaskName("Default")] +[IsDependentOn(typeof(WorldTask))] +public class DefaultTask : FrostingTask +{ +} \ No newline at end of file From 189662f1db7c6b05320e7cc245db5d714135da14 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:46:45 -0500 Subject: [PATCH 07/34] Cleaned up Cleaned up the Program.cs for the Cake Frosting project. Added the working direcotry directive --- build/Program.cs | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/build/Program.cs b/build/Program.cs index fb088c628..d26651745 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -9,49 +9,7 @@ public static int Main(string[] args) { return new CakeHost() .UseContext() + .UseWorkingDirectory("../") .Run(args); } } - -public class BuildContext : FrostingContext -{ - public bool Delay { get; set; } - - public BuildContext(ICakeContext context) - : base(context) - { - Delay = context.Arguments.HasArgument("delay"); - } -} - -[TaskName("Hello")] -public sealed class HelloTask : FrostingTask -{ - public override void Run(BuildContext context) - { - context.Log.Information("Hello"); - } -} - -[TaskName("World")] -[IsDependentOn(typeof(HelloTask))] -public sealed class WorldTask : AsyncFrostingTask -{ - // Tasks can be asynchronous - public override async Task RunAsync(BuildContext context) - { - if (context.Delay) - { - context.Log.Information("Waiting..."); - await Task.Delay(1500); - } - - context.Log.Information("World"); - } -} - -[TaskName("Default")] -[IsDependentOn(typeof(WorldTask))] -public class DefaultTask : FrostingTask -{ -} \ No newline at end of file From 1e58c09e08b01ec45aa65b9da0cc4f7b50874a27 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:48:05 -0500 Subject: [PATCH 08/34] Added BuildContext --- build/BuildContext.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 build/BuildContext.cs diff --git a/build/BuildContext.cs b/build/BuildContext.cs new file mode 100644 index 000000000..66749c933 --- /dev/null +++ b/build/BuildContext.cs @@ -0,0 +1,26 @@ +using System; +using System.Linq; +using Cake.Common; +using Cake.Common.Build; +using Cake.Common.Xml; +using Cake.Core; +using Cake.Frosting; + +namespace BuildScripts; + +public sealed class BuildContext : FrostingContext +{ + public string ArtifactsDirectory { get; } + public string Version { get; } + + public BuildContext(ICakeContext context) : base(context) + { + ArtifactsDirectory = context.Arguments(nameof(ArtifactsDirectory), "artifacts").FirstOrDefault(); + Version = context.XmlPeek("Directory.Build.targets", "/Project/PropertyGroup/Version"); + + if (context.BuildSystem().IsRunningOnGitHubActions) + { + Version += "." + context.EnvironmentVariable("GITHUB_RUN_NUMBER"); + } + } +} From 599f043d103f7c215486d04de31942afcf162862 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:48:54 -0500 Subject: [PATCH 09/34] Added BuildTask --- build/BuildTask.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 build/BuildTask.cs diff --git a/build/BuildTask.cs b/build/BuildTask.cs new file mode 100644 index 000000000..2a3cfcc40 --- /dev/null +++ b/build/BuildTask.cs @@ -0,0 +1,24 @@ +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Build; +using Cake.Common.Tools.DotNet.MSBuild; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(BuildTask))] +public sealed class BuildTask : FrostingTask +{ + public override void Run(BuildContext context) + { + DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); + msBuildSettings.WithProperty("Version", context.Version); + + DotNetBuildSettings buildSettings = new DotNetBuildSettings() + { + MSBuildSettings = msBuildSettings, + Configuration = "Release", + }; + + context.DotNetBuild("./MonoGame.Extended.sln", buildSettings); + } +} From 3ed8c941a4f144281eda3532485fc46d461ac5b9 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:49:26 -0500 Subject: [PATCH 10/34] Added Test Task --- build/TestTask.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 build/TestTask.cs diff --git a/build/TestTask.cs b/build/TestTask.cs new file mode 100644 index 000000000..ef83c3f1a --- /dev/null +++ b/build/TestTask.cs @@ -0,0 +1,22 @@ + +using Cake.Common.IO; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Test; +using Cake.Core.IO; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(TestTask))] +public class TestTask : FrostingTask +{ + public override void Run(BuildContext context) + { + DotNetTestSettings settings = new DotNetTestSettings() + { + Configuration = "Release", + }; + + context.DotNetTest("MonoGame.Extended.sln"); + } +} From 51a82aab41a384d9f0392dc7094942b80f7e7701 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:50:00 -0500 Subject: [PATCH 11/34] Added Package Task --- build/PackageTask.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 build/PackageTask.cs diff --git a/build/PackageTask.cs b/build/PackageTask.cs new file mode 100644 index 000000000..60c81f143 --- /dev/null +++ b/build/PackageTask.cs @@ -0,0 +1,34 @@ +using Cake.Common.IO; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.MSBuild; +using Cake.Common.Tools.DotNet.Pack; +using Cake.Core.IO; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(PackageTask))] +public sealed class PackageTask : FrostingTask +{ + public override void Run(BuildContext context) + { + context.CleanDirectories(context.ArtifactsDirectory); + context.CreateDirectory(context.ArtifactsDirectory); + + DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); + msBuildSettings.WithProperty("Version", context.Version); + + DotNetPackSettings packSettings = new DotNetPackSettings() + { + MSBuildSettings = msBuildSettings, + Configuration = "Release", + OutputDirectory = context.ArtifactsDirectory, + }; + + FilePathCollection files = context.GetFiles("./src/cs/MonoGame.Extended*/**/*.csproj"); + foreach(FilePath file in files) + { + context.DotNetPack(file.FullPath, packSettings); + } + } +} From 2bf02373e481d8b82e7424b0bec98c7ef118a7e7 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:50:29 -0500 Subject: [PATCH 12/34] Added Default task --- build/Program.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/Program.cs b/build/Program.cs index d26651745..b0f979a74 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -13,3 +13,10 @@ public static int Main(string[] args) .Run(args); } } + + +[TaskName("Default")] +[IsDependentOn(typeof(BuildTask))] +[IsDependentOn(typeof(TestTask))] +[IsDependentOn(typeof(PackageTask))] +public sealed class DefaultTask : FrostingTask {} From d91cc51f45ebe28d22cd120b4f52736beef014d6 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:52:16 -0500 Subject: [PATCH 13/34] Added namespace --- build/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/Program.cs b/build/Program.cs index b0f979a74..ae3c146bf 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -3,6 +3,8 @@ using Cake.Core.Diagnostics; using Cake.Frosting; +namespace BuildScripts; + public static class Program { public static int Main(string[] args) From 0245ba71dc2eaed05f87861cd4fd5568c03559e2 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:53:02 -0500 Subject: [PATCH 14/34] Cleanup using statements --- build/BuildContext.cs | 1 - build/Program.cs | 2 -- build/TestTask.cs | 2 -- 3 files changed, 5 deletions(-) diff --git a/build/BuildContext.cs b/build/BuildContext.cs index 66749c933..fb96eddeb 100644 --- a/build/BuildContext.cs +++ b/build/BuildContext.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using Cake.Common; using Cake.Common.Build; diff --git a/build/Program.cs b/build/Program.cs index ae3c146bf..5f539cd08 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; using Cake.Core; -using Cake.Core.Diagnostics; using Cake.Frosting; namespace BuildScripts; diff --git a/build/TestTask.cs b/build/TestTask.cs index ef83c3f1a..27fe67cd5 100644 --- a/build/TestTask.cs +++ b/build/TestTask.cs @@ -1,8 +1,6 @@ -using Cake.Common.IO; using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.Test; -using Cake.Core.IO; using Cake.Frosting; namespace BuildScripts; From e76a83ced3d7735de02fc0f4830b4ef4efba3e76 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 00:53:34 -0500 Subject: [PATCH 15/34] Ignore cake output directory --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4006b66e3..4c156a7f4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ # macOS .DS_Store *.user + +# cake build output +artifacts From 7701e50f89cc97e28aa0b1e571db54dd96aefcc5 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 01:11:30 -0500 Subject: [PATCH 16/34] Updated and automated for NuGet pushing --- .github/workflows/build-test-deploy.yml | 156 +++++++++--------------- 1 file changed, 55 insertions(+), 101 deletions(-) diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 0cdea9fe4..1705e0cd5 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -1,12 +1,5 @@ name: "Build test deploy" -env: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CORE_SDK_VERSION: 6.0.302 - MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }} - MYGET_SOURCE_URL: 'https://www.myget.org/F/lithiumtoast/api/v3/index.json' - on: push: branches: [develop] @@ -17,99 +10,60 @@ on: branches: [develop] jobs: - - version-job: - name: "Version" - runs-on: ubuntu-latest - - steps: - - name: "Checkout Git repository" - uses: actions/checkout@v2 - - - name: "Fetch all history for all tags and branches" - run: git fetch --prune --unshallow - - - name: "Install GitVersion" - uses: gittools/actions/gitversion/setup@v0.9.6 - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true # workaround for https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ until the execute action is updated - with: - versionSpec: '5.x' - - - name: "Use GitVersion" - uses: gittools/actions/gitversion/execute@v0.9.6 - - - run: echo "$GitVersion_NuGetVersionV2" >> version.txt - - - name: "Upload NuGetVersion version artifact" - uses: actions/upload-artifact@v2 - with: - name: version - path: version.txt - build-test-pack-job: - name: "Build" - needs: [version-job] - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest, macos-latest, ubuntu-latest] - + name: "Build-Test-Pack" + runs-on: ubuntu-latest steps: - - - name: "Download version artifact" - uses: actions/download-artifact@v2 - with: - name: version - - - name: "Read Version" - id: version - shell: bash - run: | - echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV - - - name: "Print Version" - shell: bash - run: | - echo $VERSION - - - name: "Checkout repository" - uses: actions/checkout@master - with: - submodules: true - lfs: true - - - name: "Setup .NET Core CLI" - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '${{ env.DOTNET_CORE_SDK_VERSION }}' - - - name: "Install fonts (Ubuntu)" - if: matrix.os == 'ubuntu-latest' - run: | - echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | sudo debconf-set-selections - sudo apt-get install -y ttf-mscorefonts-installer - sudo apt-get install -y fontconfig - sudo fc-cache -f -v - sudo fc-match Arial - - - name: "Download NuGet packages" - run: dotnet restore --verbosity quiet - - - name: "Build solution" - run: dotnet build --nologo --verbosity minimal --configuration Release --no-restore /p:Version='${{ env.VERSION }}' - - - name: "Test solution" - run: dotnet test --nologo --verbosity normal --configuration Release --no-build - - - name: "Pack solution" - if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' - run: dotnet pack --nologo --output "./nuget-packages" --verbosity minimal --configuration Release --no-build -p:PackageVersion='${{ env.VERSION }}' - - - name: "Add Packages Source: MyGet" - if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' - run: dotnet nuget add source $MYGET_SOURCE_URL --name "MyGet" - - - name: "Upload Packages: MyGet" - if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' - run: dotnet nuget push "./**/*.nupkg" --source "MyGet" --skip-duplicate --api-key $MYGET_ACCESS_TOKEN + - name: "Clone Repository" + uses: actions/checkout@v4 + - name: "CAKE (Build)" + run: dotnet run --project ./build/Build.csproj -- --target=BuildTask + - name: "CAKE (Test)" + run: dotnet run --project ./build/Build.csproj -- --target=TestTask + + # Creating packages does not need ot run on pull requets, just the build and + # test above. + - name: "Run CAKE Build -> Test -> Package" + if: github.event_name != 'pull_request' + run: dotnet run --project ./build/Build.csproj -- --target=Default + - name: "Package Artifacts" + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@main + with: + name: MonoGame.Extended + path: artifacts/* + + + deploy-job: + name: "Deploy Nugets" + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + needs: [build-test-pack-job] + if: ${{ github.event_name == 'push' }} + steps: + - name: "Clone Repository" + uses: actions/checkout@v4 + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: MonoGame.Extended + path: artifacts + - name: "Push Package (GitHub Feed)" + run: dotnet nuget push artifacts/*.nupkg --source https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --api-key ${GITHUB_TOKEN} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: "Push Packages (MyGet Feed)" + run: dotnet nuget push artifacts/*.nupkg --source ${MYGET_SOURCE_URL} --api-key ${MYGET_ACCESS_TOKEN} + env: + MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }} + MYGET_SOURCE_URL: 'https://www.myget.org/F/lithiumtoast/api/v3/index.json' + + # Pushes packages to nuget, but only if this is a tag release. + - name: "Push Packages (NuGet Feed)" + if: github.ref_type == 'tag' + run: dotnet nuget push artifacts/*.nupkg --source ${NUGET_SOURCE_URL} --api-key ${NUGET_ACCESS_TOKEN} + env: + NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }} + NUGET_SOURCE_URL: "https://api.nuget.org/v3/index.json" From a5ca7b886fd3ec3e24b8cdb94ed61298f9043c27 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 01:16:24 -0500 Subject: [PATCH 17/34] Check for GCLatencyMode.NoGCRegion This test fails occasionaly when run through the automated cake script. Wrapped the EndNoGCREgion in a check for GCTatencyMode.NoGCRegion to resolve --- .../Tests/MonoGame.Extended.Tests/Collections/BagTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs index 471743de2..4712ba9fe 100644 --- a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs +++ b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs @@ -35,7 +35,12 @@ public void Bag_Enumeration_Does_Not_Allocate() Assert.True(false); } - GC.EndNoGCRegion(); + // Wrap in if statement due to exception thrown when running test through + // cake build script or when debugging test script manually. + if(GCSettings.LatencyMode == GCLatencyMode.NoGCRegion) + { + GC.EndNoGCRegion(); + } } } From e1d280b3565940d841981906566eb616a0314b27 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 01:49:35 -0500 Subject: [PATCH 18/34] Forgot to add System.Runtime using statement --- src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs index 4712ba9fe..f89b45b76 100644 --- a/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs +++ b/src/cs/Tests/MonoGame.Extended.Tests/Collections/BagTests.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Xunit; From f6a8cd6e698784428a8af2a0f43b21286d215935 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 01:53:16 -0500 Subject: [PATCH 19/34] Better name for package step --- .github/workflows/build-test-deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 1705e0cd5..3de6861c8 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -23,9 +23,9 @@ jobs: # Creating packages does not need ot run on pull requets, just the build and # test above. - - name: "Run CAKE Build -> Test -> Package" + - name: "CAKE (Package)" if: github.event_name != 'pull_request' - run: dotnet run --project ./build/Build.csproj -- --target=Default + run: dotnet run --project ./build/Build.csproj -- --target=PackageTask - name: "Package Artifacts" if: github.event_name != 'pull_request' uses: actions/upload-artifact@main From e0e12e3bd1b65e4b4e7a647be5a15738cb3af489 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 01:55:19 -0500 Subject: [PATCH 20/34] NuGet Deploy only in craftworksgames repo --- .github/workflows/build-test-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 3de6861c8..59159af30 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -62,7 +62,7 @@ jobs: # Pushes packages to nuget, but only if this is a tag release. - name: "Push Packages (NuGet Feed)" - if: github.ref_type == 'tag' + if: github.ref_type == 'tag' && github.repository_owner == 'craftworkgames' run: dotnet nuget push artifacts/*.nupkg --source ${NUGET_SOURCE_URL} --api-key ${NUGET_ACCESS_TOKEN} env: NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }} From f5bee8e7a204592eff4711147305766305fcdfea Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:12:57 -0500 Subject: [PATCH 21/34] Enable Nullable in build project --- build/Build.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index 064f3a4c1..10f43d077 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -2,9 +2,10 @@ Exe net7.0 + enable $(MSBuildProjectDirectory) - \ No newline at end of file + From bd86991e6184fa739035982c14ba97b68ce125db Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:14:33 -0500 Subject: [PATCH 22/34] Add additional context variables for build script --- build/BuildContext.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/build/BuildContext.cs b/build/BuildContext.cs index fb96eddeb..286eb20c5 100644 --- a/build/BuildContext.cs +++ b/build/BuildContext.cs @@ -11,15 +11,31 @@ public sealed class BuildContext : FrostingContext { public string ArtifactsDirectory { get; } public string Version { get; } + public string SolutionPath { get; } + public string? RepositoryOwner { get; } + public string? RepositoryUrl { get; } + public bool IsTag { get; } + public bool IsRunningOnGitHubActions { get; } + public string? GitHubToken { get; } + public string? MyGetAccessToken { get; } + public string? NuGetAccessToken { get; } public BuildContext(ICakeContext context) : base(context) { - ArtifactsDirectory = context.Arguments(nameof(ArtifactsDirectory), "artifacts").FirstOrDefault(); + ArtifactsDirectory = context.Argument(nameof(ArtifactsDirectory), "artifacts"); Version = context.XmlPeek("Directory.Build.targets", "/Project/PropertyGroup/Version"); + SolutionPath = "./MonoGame.Extended.sln"; + IsRunningOnGitHubActions = context.BuildSystem().IsRunningOnGitHubActions; - if (context.BuildSystem().IsRunningOnGitHubActions) + if (IsRunningOnGitHubActions) { Version += "." + context.EnvironmentVariable("GITHUB_RUN_NUMBER"); + RepositoryOwner = context.EnvironmentVariable("GITHUB_REPOSITORY_OWNER"); + RepositoryUrl = $"https://github.com/{context.EnvironmentVariable("GITHUB_REPOSITORY")}"; + IsTag = context.EnvironmentVariable("GITHUB_REF_TYPE") == "tag"; + GitHubToken = context.EnvironmentVariable("GITHUB_TOKEN"); + MyGetAccessToken = context.EnvironmentVariable("MYGET_ACCESS_TOKEN"); + NuGetAccessToken = context.EnvironmentVariable("NUGET_ACCESS_TOKEN"); } } } From b67391d4aab55cd28a0402c8edc25b53b2104bd8 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:15:33 -0500 Subject: [PATCH 23/34] Use same verbosity, restore, and logo flags as originally used --- build/BuildTask.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/BuildTask.cs b/build/BuildTask.cs index 2a3cfcc40..0b0b784a1 100644 --- a/build/BuildTask.cs +++ b/build/BuildTask.cs @@ -17,8 +17,11 @@ public override void Run(BuildContext context) { MSBuildSettings = msBuildSettings, Configuration = "Release", + Verbosity = DotNetVerbosity.Minimal, + NoRestore = true, + NoLogo = true }; - context.DotNetBuild("./MonoGame.Extended.sln", buildSettings); + context.DotNetBuild(context.SolutionPath, buildSettings); } } From 35d21b069643b1a787954591ec2a0f08cb4165c5 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:17:11 -0500 Subject: [PATCH 24/34] Use same verbosity and nologo setting as original --- build/PackageTask.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/PackageTask.cs b/build/PackageTask.cs index 60c81f143..9f8d8ad7c 100644 --- a/build/PackageTask.cs +++ b/build/PackageTask.cs @@ -10,7 +10,7 @@ namespace BuildScripts; [TaskName(nameof(PackageTask))] public sealed class PackageTask : FrostingTask { - public override void Run(BuildContext context) + public override async void Run(BuildContext context) { context.CleanDirectories(context.ArtifactsDirectory); context.CreateDirectory(context.ArtifactsDirectory); @@ -22,6 +22,8 @@ public override void Run(BuildContext context) { MSBuildSettings = msBuildSettings, Configuration = "Release", + Verbosity = DotNetVerbosity.Minimal, + NoLogo = true, OutputDirectory = context.ArtifactsDirectory, }; From 03256fdc0d511d1e0c46d6d850b635c318ddc1a4 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:18:06 -0500 Subject: [PATCH 25/34] Created Restore task Uses same verbosity as original workflow did --- build/RestoreTask.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 build/RestoreTask.cs diff --git a/build/RestoreTask.cs b/build/RestoreTask.cs new file mode 100644 index 000000000..91c5222cf --- /dev/null +++ b/build/RestoreTask.cs @@ -0,0 +1,18 @@ +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Restore; +using Cake.Frosting; + +namespace BuildScripts; + +public sealed class RestoreTask : FrostingTask +{ + public override void Run(BuildContext context) + { + DotNetRestoreSettings restoreSettings = new DotNetRestoreSettings() + { + Verbosity = DotNetVerbosity.Quiet + }; + + context.DotNetRestore(context.SolutionPath, restoreSettings); + } +} From 5403441e02244a278a30cbcfd311ef3a689935c1 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:18:49 -0500 Subject: [PATCH 26/34] Update TestTask to use same verbosity, nologo, and nobuild as original workflow --- build/TestTask.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build/TestTask.cs b/build/TestTask.cs index 27fe67cd5..93af68392 100644 --- a/build/TestTask.cs +++ b/build/TestTask.cs @@ -1,4 +1,3 @@ - using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.Test; using Cake.Frosting; @@ -10,11 +9,14 @@ public class TestTask : FrostingTask { public override void Run(BuildContext context) { - DotNetTestSettings settings = new DotNetTestSettings() + DotNetTestSettings testSettings = new DotNetTestSettings() { Configuration = "Release", + Verbosity = DotNetVerbosity.Normal, + NoLogo = true, + NoBuild = true }; - context.DotNetTest("MonoGame.Extended.sln"); + context.DotNetTest(context.SolutionPath, testSettings); } } From 809b525e43d1212b9346eb152e8eb06f5e92f293 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:19:23 -0500 Subject: [PATCH 27/34] Create DeployToGithubTask --- build/DeployToGithubTask.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 build/DeployToGithubTask.cs diff --git a/build/DeployToGithubTask.cs b/build/DeployToGithubTask.cs new file mode 100644 index 000000000..62981e79d --- /dev/null +++ b/build/DeployToGithubTask.cs @@ -0,0 +1,25 @@ +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.NuGet.Push; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(DeployToGitHubTask))] +public sealed class DeployToGitHubTask : FrostingTask +{ + public override bool ShouldRun(BuildContext context) + { + return context.IsRunningOnGitHubActions; + } + + public override void Run(BuildContext context) + { + DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings() + { + Source = $"https://nuget.pkg.github.com/{context.RepositoryOwner}/index.json", + ApiKey = context.GitHubToken + }; + + context.DotNetNuGetPush("artifacts/*.nupkg", pushSettings); + } +} From 9d73597323ee674bef537c3ef529ba930c21d3a9 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:19:56 -0500 Subject: [PATCH 28/34] Create DeployToMyGetTask --- build/DeployToMyGetTask.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 build/DeployToMyGetTask.cs diff --git a/build/DeployToMyGetTask.cs b/build/DeployToMyGetTask.cs new file mode 100644 index 000000000..c83fe07c5 --- /dev/null +++ b/build/DeployToMyGetTask.cs @@ -0,0 +1,25 @@ +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.NuGet.Push; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(DeployToMyGetTask))] +public sealed class DeployToMyGetTask : FrostingTask +{ + public override bool ShouldRun(BuildContext context) + { + return context.IsRunningOnGitHubActions; + } + + public override void Run(BuildContext context) + { + DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings() + { + Source = $"https://www.myget.org/F/lithiumtoast/api/v3/index.json", + ApiKey = context.MyGetAccessToken + }; + + context.DotNetNuGetPush("artifacts/*.nupkg", pushSettings); + } +} From c6e472338da9b542aa8330d6a5921f82a71aaf55 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:20:18 -0500 Subject: [PATCH 29/34] Create DeployToNuGetTask --- build/DeployToNuGetTask.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 build/DeployToNuGetTask.cs diff --git a/build/DeployToNuGetTask.cs b/build/DeployToNuGetTask.cs new file mode 100644 index 000000000..846750217 --- /dev/null +++ b/build/DeployToNuGetTask.cs @@ -0,0 +1,27 @@ +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.NuGet.Push; +using Cake.Frosting; + +namespace BuildScripts; + +[TaskName(nameof(DeployToNuGetTask))] +public sealed class DeployToNuGetTask : FrostingTask +{ + public override bool ShouldRun(BuildContext context) + { + return context.IsRunningOnGitHubActions && + context.IsTag && + context.RepositoryOwner == "craftworksgames"; + } + + public override void Run(BuildContext context) + { + DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings() + { + Source = $"https://api.nuget.org/v3/index.json", + ApiKey = context.NuGetAccessToken + }; + + context.DotNetNuGetPush("artifacts/*.nupkg", pushSettings); + } +} From 09abeb92ffa6eeb284b3cac8c7587a56a0a40013 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:20:54 -0500 Subject: [PATCH 30/34] Added Deploy task --- build/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build/Program.cs b/build/Program.cs index 5f539cd08..cca32654f 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -1,4 +1,9 @@ +using System.Threading.Tasks; +using Cake.Common.Build; +using Cake.Common.IO; +using Cake.Common.Tools.ReportUnit; using Cake.Core; +using Cake.Core.IO; using Cake.Frosting; namespace BuildScripts; @@ -14,9 +19,16 @@ public static int Main(string[] args) } } - [TaskName("Default")] +[IsDependentOn(typeof(RestoreTask))] [IsDependentOn(typeof(BuildTask))] [IsDependentOn(typeof(TestTask))] [IsDependentOn(typeof(PackageTask))] public sealed class DefaultTask : FrostingTask {} + + +[TaskName("Deploy")] +[IsDependentOn(typeof(DeployToGitHubTask))] +[IsDependentOn(typeof(DeployToMyGetTask))] +[IsDependentOn(typeof(DeployToNuGetTask))] +public sealed class DeployTask : FrostingTask {} From 16e8a825d10cd99539e141940c01e544771def49 Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:21:39 -0500 Subject: [PATCH 31/34] Simplify, move most logic into cake build script --- .github/workflows/build-test-deploy.yml | 34 +++++-------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 59159af30..2786eb0c0 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -2,7 +2,7 @@ name: "Build test deploy" on: push: - branches: [develop] + branches: [develop, test/feature] tags: [v*] pull_request: branches: [develop] @@ -16,24 +16,15 @@ jobs: steps: - name: "Clone Repository" uses: actions/checkout@v4 - - name: "CAKE (Build)" - run: dotnet run --project ./build/Build.csproj -- --target=BuildTask - - name: "CAKE (Test)" - run: dotnet run --project ./build/Build.csproj -- --target=TestTask - - # Creating packages does not need ot run on pull requets, just the build and - # test above. - - name: "CAKE (Package)" - if: github.event_name != 'pull_request' - run: dotnet run --project ./build/Build.csproj -- --target=PackageTask - - name: "Package Artifacts" + - name: "CAKE (Build -> Test -> Package)" + run: dotnet run --project ./build/Build.csproj -- --target=Default + - name: "Upload Artifacts For Deploy" if: github.event_name != 'pull_request' uses: actions/upload-artifact@main with: name: MonoGame.Extended path: artifacts/* - deploy-job: name: "Deploy Nugets" runs-on: ubuntu-latest @@ -45,25 +36,14 @@ jobs: steps: - name: "Clone Repository" uses: actions/checkout@v4 - - name: Download Artifacts + - name: "Download Artifacts For Deploy" uses: actions/download-artifact@v3 with: name: MonoGame.Extended path: artifacts - - name: "Push Package (GitHub Feed)" - run: dotnet nuget push artifacts/*.nupkg --source https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --api-key ${GITHUB_TOKEN} + - name: "Push Package" + run: dotnet run --project ./build/Build.csproj -- --target=Deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: "Push Packages (MyGet Feed)" - run: dotnet nuget push artifacts/*.nupkg --source ${MYGET_SOURCE_URL} --api-key ${MYGET_ACCESS_TOKEN} - env: MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }} - MYGET_SOURCE_URL: 'https://www.myget.org/F/lithiumtoast/api/v3/index.json' - - # Pushes packages to nuget, but only if this is a tag release. - - name: "Push Packages (NuGet Feed)" - if: github.ref_type == 'tag' && github.repository_owner == 'craftworkgames' - run: dotnet nuget push artifacts/*.nupkg --source ${NUGET_SOURCE_URL} --api-key ${NUGET_ACCESS_TOKEN} - env: NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }} - NUGET_SOURCE_URL: "https://api.nuget.org/v3/index.json" From fac64ccd748850a7f839c9ecb4e2399749c4d652 Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 13:32:35 -0500 Subject: [PATCH 32/34] Ignore Missing XML comment warnings on build --- build/BuildTask.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/BuildTask.cs b/build/BuildTask.cs index 0b0b784a1..218c2095d 100644 --- a/build/BuildTask.cs +++ b/build/BuildTask.cs @@ -12,6 +12,8 @@ public override void Run(BuildContext context) { DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); msBuildSettings.WithProperty("Version", context.Version); + msBuildSettings.WithProperty("NoWarn", "CS1591"); + DotNetBuildSettings buildSettings = new DotNetBuildSettings() { From 3ae6aa4b14ca21d4e2f7c800abd3036bb1e5f6ed Mon Sep 17 00:00:00 2001 From: Christopher Whitley Date: Thu, 16 Nov 2023 13:32:50 -0500 Subject: [PATCH 33/34] Remove async, ignore NU5118 on package --- build/PackageTask.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/PackageTask.cs b/build/PackageTask.cs index 9f8d8ad7c..a01752aa8 100644 --- a/build/PackageTask.cs +++ b/build/PackageTask.cs @@ -1,3 +1,4 @@ +using Cake.Common.Build; using Cake.Common.IO; using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.MSBuild; @@ -10,7 +11,7 @@ namespace BuildScripts; [TaskName(nameof(PackageTask))] public sealed class PackageTask : FrostingTask { - public override async void Run(BuildContext context) + public override void Run(BuildContext context) { context.CleanDirectories(context.ArtifactsDirectory); context.CreateDirectory(context.ArtifactsDirectory); @@ -18,6 +19,9 @@ public override async void Run(BuildContext context) DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); msBuildSettings.WithProperty("Version", context.Version); + // Ignore warnings about adding duplicate items added to package + msBuildSettings.WithProperty("NoWarn", "NU5118") + DotNetPackSettings packSettings = new DotNetPackSettings() { MSBuildSettings = msBuildSettings, From f4b29420b59763af56ba3f14e5ce7a9fd55560eb Mon Sep 17 00:00:00 2001 From: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:07:51 -0500 Subject: [PATCH 34/34] Apparently i forgot a semi colon.... --- build/PackageTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/PackageTask.cs b/build/PackageTask.cs index a01752aa8..b1c56ab4d 100644 --- a/build/PackageTask.cs +++ b/build/PackageTask.cs @@ -20,7 +20,7 @@ public override void Run(BuildContext context) msBuildSettings.WithProperty("Version", context.Version); // Ignore warnings about adding duplicate items added to package - msBuildSettings.WithProperty("NoWarn", "NU5118") + msBuildSettings.WithProperty("NoWarn", "NU5118"); DotNetPackSettings packSettings = new DotNetPackSettings() {