Skip to content

Commit ce5f41a

Browse files
Develop (#95)
* Feature/cake frosting (#92) * Added games list Add list of games made with MonoGame.Aseprite * Always specify generate documentation file * Switch to Cake Frosting * Update workflow script * Issue/try get slice 92 (#94) * Added MonoGame.Aseprite to Test .sln This is so intellesense would pickup correct * Added test for issue #92 * Use `_slices` and not `_tags` The `AsepriteSlice.TryGetSlice(string, out AsepriteSlice?)` method incorrectly searched the `_tags` array and not the `_slices` array. This resolves issue #92 * Bump version number * Update release notes
1 parent 8d92eeb commit ce5f41a

File tree

22 files changed

+372
-464
lines changed

22 files changed

+372
-464
lines changed

.build/Build.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<PackageReference Include="Cake.Frosting" Version="3.1.0" />
10+
</ItemGroup>
11+
</Project>

.build/Build.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build.csproj", "{86E7FFCA-81BE-403B-A2EE-61D4C8526111}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

.build/BuildContext.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.IO;
2+
using Cake.Common;
3+
using Cake.Common.Build;
4+
using Cake.Common.Xml;
5+
using Cake.Core;
6+
using Cake.Frosting;
7+
8+
namespace BuildScripts;
9+
10+
public sealed class BuildContext : FrostingContext
11+
{
12+
public readonly string ArtifactsDirectory;
13+
public readonly string Version;
14+
public readonly string? RepositoryOwner;
15+
public readonly string? RepositoryUrl;
16+
public readonly bool IsTag;
17+
public readonly bool IsRunningOnGitHubActions;
18+
public readonly string? GitHubToken;
19+
public readonly string? NuGetAccessToken;
20+
public readonly string MonoGameAsepritePath;
21+
public readonly string MonoGameAsepriteContentPipelinePath;
22+
public readonly string MonoGameAsepriteTestsPath;
23+
24+
public BuildContext(ICakeContext context) : base(context)
25+
{
26+
ArtifactsDirectory = context.Argument(nameof(ArtifactsDirectory), ".artifacts");
27+
MonoGameAsepritePath = context.Argument(nameof(MonoGameAsepritePath), "source/MonoGame.Aseprite/MonoGame.Aseprite.csproj");
28+
MonoGameAsepriteContentPipelinePath = context.Argument(nameof(MonoGameAsepriteContentPipelinePath), "source/MonoGame.Aseprite.Content.Pipeline/MonoGame.Aseprite.Content.Pipeline.csproj");
29+
MonoGameAsepriteTestsPath = context.Argument(nameof(MonoGameAsepriteTestsPath), "tests/MonoGame.Aseprite.Tests/MonoGame.Aseprite.Tests.csproj");
30+
Version = context.XmlPeek("source/MonoGame.Aseprite/MonoGame.Aseprite.csproj", "/Project/PropertyGroup/Version");
31+
32+
IsRunningOnGitHubActions = context.BuildSystem().IsRunningOnGitHubActions;
33+
if (IsRunningOnGitHubActions)
34+
{
35+
RepositoryOwner = context.EnvironmentVariable("GITHUB_REPOSITORY_OWNER");
36+
RepositoryUrl = $"https://github.com/{context.EnvironmentVariable("GITHUB_REPOSITORY")}";
37+
GitHubToken = context.EnvironmentVariable("GITHUB_TOKEN");
38+
IsTag = context.EnvironmentVariable("GITHUB_REF_TYPE") == "tag";
39+
40+
if (IsTag)
41+
{
42+
NuGetAccessToken = context.EnvironmentVariable("NUGET_ACCESS_TOKEN");
43+
}
44+
}
45+
}
46+
47+
48+
}

.build/BuildTask.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Cake.Common.Tools.DotNet;
2+
using Cake.Common.Tools.DotNet.Build;
3+
using Cake.Common.Tools.DotNet.MSBuild;
4+
using Cake.Frosting;
5+
6+
namespace BuildScripts;
7+
8+
[TaskName(nameof(BuildTask))]
9+
public sealed class BuildTask : FrostingTask<BuildContext>
10+
{
11+
public override void Run(BuildContext context)
12+
{
13+
DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings();
14+
msBuildSettings.WithProperty("Version", context.Version);
15+
16+
DotNetBuildSettings buildSettings = new DotNetBuildSettings()
17+
{
18+
MSBuildSettings = msBuildSettings,
19+
Configuration = "Release",
20+
Verbosity = DotNetVerbosity.Minimal,
21+
NoLogo = true
22+
};
23+
24+
context.DotNetBuild(context.MonoGameAsepritePath, buildSettings);
25+
context.DotNetBuild(context.MonoGameAsepriteContentPipelinePath, buildSettings);
26+
context.DotNetBuild(context.MonoGameAsepriteTestsPath, buildSettings);
27+
}
28+
}

.build/DeployToGithubTask.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Cake.Common.Tools.DotNet;
2+
using Cake.Common.Tools.DotNet.NuGet.Push;
3+
using Cake.Frosting;
4+
5+
namespace BuildScripts;
6+
7+
[TaskName(nameof(DeployToGitHubTask))]
8+
public sealed class DeployToGitHubTask : FrostingTask<BuildContext>
9+
{
10+
public override bool ShouldRun(BuildContext context) => context.IsRunningOnGitHubActions;
11+
12+
public override void Run(BuildContext context)
13+
{
14+
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings()
15+
{
16+
Source = $"https://nuget.pkg.github.com/{context.RepositoryOwner}/index.json",
17+
ApiKey = context.GitHubToken
18+
};
19+
20+
context.DotNetNuGetPush($"{context.ArtifactsDirectory}/*.nupkg", pushSettings);
21+
}
22+
}

.build/DeployToNuGetTask.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using Cake.Common.Tools.DotNet;
3+
using Cake.Common.Tools.DotNet.NuGet.Push;
4+
using Cake.Frosting;
5+
6+
namespace BuildScripts;
7+
8+
[TaskName(nameof(DeployToNuGetTask))]
9+
public sealed class DeployToNuGetTask : FrostingTask<BuildContext>
10+
{
11+
public override bool ShouldRun(BuildContext context) =>
12+
context.IsRunningOnGitHubActions &&
13+
context.IsTag &&
14+
!string.IsNullOrEmpty(context.RepositoryOwner) &&
15+
context.RepositoryOwner.Equals("AristurtleDev", StringComparison.InvariantCultureIgnoreCase);
16+
17+
18+
public override void Run(BuildContext context)
19+
{
20+
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings()
21+
{
22+
Source = "https://api.nuget.org/v3/index.json",
23+
ApiKey = context.NuGetAccessToken
24+
};
25+
26+
context.DotNetNuGetPush($"{context.ArtifactsDirectory}/*.nupkg", pushSettings);
27+
}
28+
}

.build/PackageTask.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Cake.Common.IO;
2+
using Cake.Common.Tools.DotNet;
3+
using Cake.Common.Tools.DotNet.MSBuild;
4+
using Cake.Common.Tools.DotNet.Pack;
5+
using Cake.Frosting;
6+
7+
namespace BuildScripts;
8+
9+
[TaskName(nameof(PackageTask))]
10+
public sealed class PackageTask : FrostingTask<BuildContext>
11+
{
12+
public override void Run(BuildContext context)
13+
{
14+
context.CleanDirectory(context.ArtifactsDirectory);
15+
context.CreateDirectory(context.ArtifactsDirectory);
16+
17+
DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings();
18+
msBuildSettings.WithProperty("Version", context.Version);
19+
msBuildSettings.WithProperty("PackageVersion", context.Version);
20+
21+
DotNetPackSettings packSettings = new DotNetPackSettings()
22+
{
23+
Configuration = "Release",
24+
OutputDirectory = context.ArtifactsDirectory,
25+
MSBuildSettings = msBuildSettings
26+
};
27+
28+
context.DotNetPack(context.MonoGameAsepritePath, packSettings);
29+
}
30+
}

.build/Program.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Threading.Tasks;
2+
using Cake.Core;
3+
using Cake.Core.Diagnostics;
4+
using Cake.Frosting;
5+
6+
namespace BuildScripts;
7+
8+
public static class Program
9+
{
10+
public static int Main(string[] args)
11+
{
12+
return new CakeHost()
13+
.UseContext<BuildContext>()
14+
.UseWorkingDirectory("../")
15+
.Run(args);
16+
}
17+
}
18+
19+
[TaskName("Default")]
20+
[IsDependentOn(typeof(RestoreTask))]
21+
[IsDependentOn(typeof(BuildTask))]
22+
[IsDependentOn(typeof(TestTask))]
23+
[IsDependentOn(typeof(PackageTask))]
24+
public sealed class DefaultTask : FrostingTask {}
25+
26+
[TaskName("Deploy")]
27+
[IsDependentOn(typeof(DeployToGitHubTask))]
28+
[IsDependentOn(typeof(DeployToNuGetTask))]
29+
public sealed class DeployTask : FrostingTask {}

.build/RestoreTask.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Cake.Common.Tools.DotNet;
2+
using Cake.Common.Tools.DotNet.Restore;
3+
using Cake.Frosting;
4+
5+
namespace BuildScripts;
6+
7+
[TaskName(nameof(RestoreTask))]
8+
public sealed class RestoreTask : FrostingTask<BuildContext>
9+
{
10+
public override void Run(BuildContext context)
11+
{
12+
DotNetRestoreSettings restoreSettings = new DotNetRestoreSettings()
13+
{
14+
Verbosity = DotNetVerbosity.Quiet
15+
};
16+
context.DotNetRestore(context.MonoGameAsepritePath, restoreSettings);
17+
context.DotNetRestore(context.MonoGameAsepriteContentPipelinePath, restoreSettings);
18+
context.DotNetRestore(context.MonoGameAsepriteTestsPath, restoreSettings);
19+
}
20+
}

.build/TestTask.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Cake.Common.Tools.DotNet;
2+
using Cake.Common.Tools.DotNet.Test;
3+
using Cake.Frosting;
4+
5+
namespace BuildScripts;
6+
7+
[TaskName(nameof(TestTask))]
8+
public sealed class TestTask : FrostingTask<BuildContext>
9+
{
10+
public override void Run(BuildContext context)
11+
{
12+
DotNetTestSettings testSettings = new DotNetTestSettings()
13+
{
14+
Configuration = "Release",
15+
};
16+
context.DotNetTest(context.MonoGameAsepriteTestsPath, testSettings);
17+
}
18+
}

0 commit comments

Comments
 (0)