From 78f34439525a16e1d13ea0dee808c7a43428dc87 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Mon, 19 Aug 2024 15:11:23 +0100 Subject: [PATCH] Add support for specifying a readme (required). --- PackContext.cs | 3 +++ Resources/MonoGame.Tool.X.txt | 2 ++ Tasks/PublishPackageTask.cs | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/PackContext.cs b/PackContext.cs index 0eb5383..8458688 100644 --- a/PackContext.cs +++ b/PackContext.cs @@ -13,6 +13,8 @@ public class PackContext public string LicensePath { get; } + public string ReadMePath { get; } + public string? RepositoryOwner { get; } public string? RepositoryUrl { get; } @@ -27,6 +29,7 @@ public PackContext(ICakeContext context) CommandName = context.Argument("commandname", "X"); ExecutableName = context.Argument("executablename", "X"); LicensePath = context.Argument("licensepath", ""); + ReadMePath = context.Argument("readmepath", ""); Version = context.Argument("version", "1.0.0"); RepositoryUrl = "X"; IsTag = false; diff --git a/Resources/MonoGame.Tool.X.txt b/Resources/MonoGame.Tool.X.txt index d9b4b13..e1fa26a 100644 --- a/Resources/MonoGame.Tool.X.txt +++ b/Resources/MonoGame.Tool.X.txt @@ -17,11 +17,13 @@ Icon.png {CommandName} {LicenseName} + {ReadMeName} {CommandName} + diff --git a/Tasks/PublishPackageTask.cs b/Tasks/PublishPackageTask.cs index 5494084..9ca14b4 100644 --- a/Tasks/PublishPackageTask.cs +++ b/Tasks/PublishPackageTask.cs @@ -63,13 +63,21 @@ public override async Task RunAsync(BuildContext context) if (licensePath.EndsWith(".txt")) licenseName += ".txt"; else if (licensePath.EndsWith(".md")) licenseName += ".md"; + var readMePath = context.PackContext.ReadMePath; + var readMeName = "README"; + + if (readMePath.EndsWith(".txt")) readMeName += ".txt"; + else if (readMePath.EndsWith(".md")) readMeName += ".md"; + var contentInclude = $""; var projectData = await ReadEmbeddedResourceAsync("MonoGame.Tool.X.txt"); projectData = projectData.Replace("{X}", context.PackContext.ToolName) .Replace("{CommandName}", context.PackContext.CommandName) .Replace("{LicensePath}", context.PackContext.LicensePath) + .Replace("{ReadMePath}", context.PackContext.ReadMePath) .Replace("{LicenseName}", licenseName) + .Replace("{ReadMeName}", readMeName) .Replace("{ContentInclude}", contentInclude); string projectPath = $"{projectDir}/MonoGame.Tool.{context.PackContext.ToolName}.csproj";