Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions src/Cake.Common.Tests/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/Cake.Common.Tests/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,4 +1559,38 @@ EndGlobal</value>
&lt;/Solution&gt;
</value>
</data>
<data name="Nuspec_ReadMe" xml:space="preserve">
<value>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"&gt;
&lt;id&gt;The ID&lt;/id&gt;
&lt;version&gt;The version&lt;/version&gt;
&lt;title&gt;The title&lt;/title&gt;
&lt;authors&gt;Author #1,Author #2&lt;/authors&gt;
&lt;owners&gt;Owner #1,Owner #2&lt;/owners&gt;
&lt;licenseUrl&gt;https://license.com&lt;/licenseUrl&gt;
&lt;projectUrl&gt;https://project.com&lt;/projectUrl&gt;
&lt;icon&gt;images\icon.png&lt;/icon&gt;
&lt;iconUrl&gt;https://icon.com&lt;/iconUrl&gt;
&lt;requireLicenseAcceptance&gt;true&lt;/requireLicenseAcceptance&gt;
&lt;developmentDependency&gt;true&lt;/developmentDependency&gt;
&lt;description&gt;The description&lt;/description&gt;
&lt;summary&gt;The summary&lt;/summary&gt;
&lt;copyright&gt;The copyright&lt;/copyright&gt;
&lt;language&gt;en-us&lt;/language&gt;
&lt;tags&gt;Tag1 Tag2 Tag3&lt;/tags&gt;
&lt;serviceable&gt;true&lt;/serviceable&gt;
&lt;readme&gt;NuGet.org.md&lt;/readme&gt;
&lt;releaseNotes&gt;&lt;![CDATA[Line #1
Line #2
Line #3]]&gt;&lt;/releaseNotes&gt;
&lt;/metadata&gt;
&lt;files&gt;
&lt;file src="Cake.Core.dll" target="lib/net45" /&gt;
&lt;file src="Cake.Core.xml" target="lib/net45" /&gt;
&lt;file src="Cake.Core.pdb" target="lib/net45" /&gt;
&lt;file src="LICENSE" /&gt;
&lt;/files&gt;
&lt;/package&gt;</value>
</data>
</root>
36 changes: 36 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/NuGet/Pack/NuGetPackerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,42 @@ public void Should_Replace_Template_Tokens_In_Nuspec_With_Files_And_DependencyTa
Resources.Nuspec_Metadata_WithoutNamespaces_WithTargetFramworkDependencies.NormalizeLineEndings(),
result.NuspecContent.NormalizeLineEndings());
}

[Fact]
public void Should_Add_ReadMe_Element_To_Nuspec_If_Missing()
{
// Given
var fixture = new NuGetPackerWithNuSpecFixture();
fixture.WithNuSpecXml(Resources.Nuspec_NoMetadataElement);

fixture.Settings.Id = "The ID";
fixture.Settings.Version = "The version";
fixture.Settings.Title = "The title";
fixture.Settings.Authors = new[] { "Author #1", "Author #2" };
fixture.Settings.Owners = new[] { "Owner #1", "Owner #2" };
fixture.Settings.Description = "The description";
fixture.Settings.Summary = "The summary";
fixture.Settings.LicenseUrl = new Uri("https://license.com");
fixture.Settings.ProjectUrl = new Uri("https://project.com");
fixture.Settings.Icon = @"images\icon.png";
fixture.Settings.IconUrl = new Uri("https://icon.com");
fixture.Settings.DevelopmentDependency = true;
fixture.Settings.RequireLicenseAcceptance = true;
fixture.Settings.Copyright = "The copyright";
fixture.Settings.ReleaseNotes = new[] { "Line #1", "Line #2", "Line #3" };
fixture.Settings.Tags = new[] { "Tag1", "Tag2", "Tag3" };
fixture.Settings.Language = "en-us";
fixture.Settings.Serviceable = true;
fixture.Settings.ReadMe = "NuGet.org.md";

// When
var result = fixture.Run();

// Then
Assert.Equal(
Resources.Nuspec_ReadMe.NormalizeLineEndings(),
result.NuspecContent.NormalizeLineEndings());
}
}

public sealed class WithProjectFile
Expand Down
9 changes: 9 additions & 0 deletions src/Cake.Common/Tools/NuGet/Pack/NuGetPackSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,14 @@ public sealed class NuGetPackSettings : ToolSettings
/// <c>true</c> if the output should be placed in the tool folder inside the NuGet package; otherwise <c>false</c>.
/// </value>
public bool OutputToToolFolder { get; set; }

/// <summary>
/// Gets or sets the path to the readme file in the package.
/// The file needs to be part of the package files.
/// </summary>
/// <value>
/// The path to a file included in the package, relative to the root of the package.
/// </value>
public FilePath ReadMe { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/Cake.Common/Tools/NuGet/Pack/NuspecTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ private static IDictionary<string, Func<NuGetPackSettings, string>> CreateMappin
{ "copyright", x => ToString(settings.Copyright) },
{ "language", x => ToString(settings.Language) },
{ "tags", x => ToSpaceSeparatedString(settings.Tags) },
{ "serviceable", x => ToString(settings.Serviceable) }
{ "serviceable", x => ToString(settings.Serviceable) },
{ "readme", x => ToString(settings.ReadMe?.FullPath) }
};
}

Expand Down
Loading