Skip to content

Commit

Permalink
Add support for specifying a readme (required).
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Aug 19, 2024
1 parent 1eebfc4 commit 78f3443
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PackContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class PackContext

public string LicensePath { get; }

public string ReadMePath { get; }

public string? RepositoryOwner { get; }

public string? RepositoryUrl { get; }
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Resources/MonoGame.Tool.X.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<PackageIcon>Icon.png</PackageIcon>
<PackageId>{CommandName}</PackageId>
<PackageLicenseFile>{LicenseName}</PackageLicenseFile>
<PackageReadmeFile>{ReadMeName}</PackageReadmeFile>
<ToolCommandName>{CommandName}</ToolCommandName>
</PropertyGroup>

<ItemGroup>
<None Include="../{LicensePath}" Pack="true" PackagePath="" />
<None Include="../{ReadMePath}" Pack="true" PackagePath="" />
<None Include="Icon.png" Pack="true" PackagePath="" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions Tasks/PublishPackageTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $"<None Include=\"binaries\\**\\*\" CopyToOutputDirectory=\"PreserveNewest\" />";

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";
Expand Down

0 comments on commit 78f3443

Please sign in to comment.