-
-
Notifications
You must be signed in to change notification settings - Fork 770
GH3517: Add NuGet Pack ReadMe Support #3518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 => settings.ReadMePath is { } readme ? string.Concat("docs\\", readme.GetFilename().FullPath) : null }, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same as above: AFAIK there's no requirement for the README to be in a |
||||||
| }; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -108,17 +109,25 @@ private static void AddComplexTypesToXmlDocument(XmlDocument document, NuGetPack | |||||
| private static void CreateFileElements(XmlDocument document, NuGetPackSettings settings, | ||||||
| XmlNamespaceManager namespaceManager) | ||||||
| { | ||||||
| if (settings.Files != null && settings.Files.Count > 0) | ||||||
| var hasFiles = settings.Files != null && settings.Files.Count > 0; | ||||||
| var hasReadMe = settings.ReadMePath != null; | ||||||
|
|
||||||
| if (!hasFiles && !hasReadMe) | ||||||
| { | ||||||
| var filesPath = string.Format(CultureInfo.InvariantCulture, | ||||||
| "//*[local-name()='package']/*[local-name()='files']"); | ||||||
| var filesElement = document.SelectSingleNode(filesPath, namespaceManager); | ||||||
| if (filesElement == null) | ||||||
| { | ||||||
| var package = GetPackageElement(document); | ||||||
| filesElement = document.CreateAndAppendElement(package, "files"); | ||||||
| } | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| var filesPath = string.Format(CultureInfo.InvariantCulture, | ||||||
| "//*[local-name()='package']/*[local-name()='files']"); | ||||||
| var filesElement = document.SelectSingleNode(filesPath, namespaceManager); | ||||||
| if (filesElement == null) | ||||||
| { | ||||||
| var package = GetPackageElement(document); | ||||||
| filesElement = document.CreateAndAppendElement(package, "files"); | ||||||
| } | ||||||
|
|
||||||
| if (hasFiles) | ||||||
| { | ||||||
| filesElement.RemoveAll(); | ||||||
| foreach (var file in settings.Files) | ||||||
| { | ||||||
|
|
@@ -131,6 +140,13 @@ private static void CreateFileElements(XmlDocument document, NuGetPackSettings s | |||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (hasReadMe) | ||||||
| { | ||||||
| var fileElement = document.CreateAndAppendElement(filesElement, "file"); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't actually run this to test, but I'm under the impression the README could already be present in the list of files - wouldn't this duplicate the entry in the nuspec? |
||||||
| fileElement.AddAttributeIfSpecified(settings.ReadMePath.FullPath, "src"); | ||||||
| fileElement.AddAttributeIfSpecified("docs", "target"); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: AFAIK there's no requirement for the README to be in a |
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private static void CreateContentFileElements(XmlDocument document, NuGetPackSettings settings, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there's no requirement for the README to be in a
docsfolder - it can be anywhere in the package. Most of the examples I see have theREADME.mdfile at the root of the package