Skip to content
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

Readme support for packages #3634

Merged
merged 2 commits into from
Mar 15, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public DetailedPackageMetadata(PackageSearchMetadataContextInfo serverData, Pack
IconUrl = serverData.IconUrl;
LicenseUrl = serverData.LicenseUrl;
ProjectUrl = serverData.ProjectUrl;
ReadmeUrl = serverData.ReadmeUrl;
ReportAbuseUrl = serverData.ReportAbuseUrl;
// Some server implementations send down an array with an empty string, which ends up as an empty string.
// In PM UI, we want Tags to work like most other properties from the server (Authors/Owners), and be null, if there is no value.
Expand Down Expand Up @@ -89,6 +90,8 @@ public DetailedPackageMetadata(PackageSearchMetadataContextInfo serverData, Pack

public Uri ProjectUrl { get; set; }

public Uri ReadmeUrl { get; set; }

public Uri ReportAbuseUrl { get; set; }

public Uri PackageDetailsUrl { get; set; }
Expand Down

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

9 changes: 9 additions & 0 deletions src/NuGet.Clients/NuGet.PackageManagement.UI/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@
<data name="Label_Publishers" xml:space="preserve">
<value>Publisher(s):</value>
</data>
<data name="Label_Readme" xml:space="preserve">
<value>Readme:</value>
</data>
<data name="Label_Repository" xml:space="preserve">
<value>Package source:</value>
</data>
Expand Down Expand Up @@ -432,6 +435,9 @@ Packages installed into Website projects will not be restored during build. Cons
<data name="Text_ViewLicense" xml:space="preserve">
<value>View License</value>
</data>
<data name="Text_ViewReadme" xml:space="preserve">
<value>View Readme</value>
</data>
<data name="Text_NotAvailableInSource" xml:space="preserve">
<value>Not available in this source</value>
</data>
Expand Down Expand Up @@ -897,6 +903,9 @@ Please see https://aka.ms/troubleshoot_nuget_cache for more help.</value>
<data name="Hyperlink_ProjectUrl" xml:space="preserve">
<value>Project URL</value>
</data>
<data name="Hyperlink_Readme" xml:space="preserve">
<value>Readme</value>
</data>
<data name="Hyperlink_ReportAbuse" xml:space="preserve">
<value>Report Abuse</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Expand Down Expand Up @@ -202,10 +203,37 @@
</ItemsControl.ItemsPanel>
</ItemsControl>

<!-- Readme -->
<TextBlock
Visibility="{Binding Path=ReadmeUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="4"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
x:Name="_readmeLabel"
AutomationProperties.Name="{Binding Text}"
Text="{x:Static nuget:Resources.Label_Readme}"/>

<TextBlock
Visibility="{Binding Path=ReadmeUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="4"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=ReadmeUrl}"
Style="{StaticResource HyperlinkStyle}"
Command="{x:Static nuget:PackageManagerControlCommands.OpenExternalLink}"
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=NavigateUri}"
AutomationProperties.Name="{x:Static nuget:Resources.Hyperlink_Readme}">
<Run Text="{x:Static nuget:Resources.Text_ViewReadme}" />
</Hyperlink>
</TextBlock>

<!-- downloads -->
<TextBlock
Visibility="{Binding Path=DownloadCount,Converter={StaticResource DownloadCountToVisibilityConverter}}"
Grid.Row="4"
Grid.Row="5"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -218,13 +246,13 @@
Text="{Binding Path=DownloadCount,StringFormat={}{0:N0}}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="4"
Grid.Row="5"
Grid.Column="1" />

<!--Date Published -->
<TextBlock
Visibility="{Binding Path=Published,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="5"
Grid.Row="6"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -238,13 +266,13 @@
AutomationProperties.LabeledBy="{Binding ElementName=_datePublishedLabel}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="5"
Grid.Row="6"
Grid.Column="1" />

<!-- Project Url -->
<TextBlock
Visibility="{Binding Path=ProjectUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="6"
Grid.Row="7"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -256,7 +284,7 @@
Visibility="{Binding Path=ProjectUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="6"
Grid.Row="7"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=ProjectUrl}"
Expand All @@ -270,7 +298,7 @@
<!-- Report abuse Url -->
<TextBlock
Visibility="{Binding Path=ReportAbuseUrl,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="7"
Grid.Row="8"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -281,7 +309,7 @@
Visibility="{Binding Path=ReportAbuseUrl,Converter={StaticResource NullToVisibilityConverter}}"
TextWrapping="Wrap"
Margin="8,8,0,0"
Grid.Row="7"
Grid.Row="8"
Grid.Column="1">
<Hyperlink
NavigateUri="{Binding Path=ReportAbuseUrl}"
Expand All @@ -295,7 +323,7 @@
<!-- Tags -->
<TextBlock
Visibility="{Binding Path=Tags,Converter={StaticResource NullToVisibilityConverter}}"
Grid.Row="8"
Grid.Row="9"
Grid.Column="0"
FontWeight="Bold"
Margin="0,8,0,0"
Expand All @@ -308,7 +336,7 @@
Text="{Binding Path=Tags}"
Margin="8,8,0,0"
TextWrapping="Wrap"
Grid.Row="8"
Grid.Row="9"
Grid.Column="1" />
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class PackageSearchMetadataContextInfo
public Uri? IconUrl { get; internal set; }
public string? Tags { get; internal set; }
public Uri? LicenseUrl { get; internal set; }
public Uri? ReadmeUrl { get; internal set; }
public string? Owners { get; internal set; }
public Uri? ProjectUrl { get; internal set; }
public DateTimeOffset? Published { get; internal set; }
Expand Down Expand Up @@ -54,6 +55,7 @@ public static PackageSearchMetadataContextInfo Create(IPackageSearchMetadata pac
Tags = packageSearchMetadata.Tags,
Identity = packageSearchMetadata.Identity,
LicenseUrl = packageSearchMetadata.LicenseUrl,
ReadmeUrl = packageSearchMetadata.ReadmeUrl,
LicenseMetadata = packageSearchMetadata.LicenseMetadata,
IsRecommended = isRecommended,
RecommenderVersion = recommenderVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
NuGet.VisualStudio.Internal.Contracts.PackageDeprecationMetadataContextInfo.Message.get -> string?
NuGet.VisualStudio.Internal.Contracts.PackageDeprecationMetadataContextInfo.PackageDeprecationMetadataContextInfo(string? message, System.Collections.Generic.IReadOnlyCollection<string!>? reasons, NuGet.VisualStudio.Internal.Contracts.AlternatePackageMetadataContextInfo? alternatePackageContextInfo) -> void
NuGet.VisualStudio.Internal.Contracts.PackageSearchMetadataContextInfo.ReadmeUrl.get -> System.Uri?
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public interface IPackTaskRequest<TItem>
string PackageLicenseExpression { get; }
string PackageLicenseExpressionVersion { get; }
string PackageLicenseFile { get; }
string Readme { get; }
bool Deterministic { get; }
string PackageIcon { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Copyright (c) .NET Foundation. All rights reserved.
PackageLicenseFile="$(PackageLicenseFile)"
PackageLicenseExpression="$(PackageLicenseExpression)"
PackageLicenseExpressionVersion="$(PackageLicenseExpressionVersion)"
Readme="$(PackageReadmeFile)"
Deterministic="$(Deterministic)"
PackageIcon="$(PackageIcon)"
/>
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class PackTask : Microsoft.Build.Utilities.Task, IPackTaskRequest<ITaskIt
public string PackageLicenseExpression { get; set; }
public string PackageLicenseFile { get; set; }
public string PackageLicenseExpressionVersion { get; set; }
public string Readme { get; set; }
public bool Deterministic { get; set; }
public string PackageIcon { get; set; }
public ILogger Logger => new MSBuildLogger(Log);
Expand Down Expand Up @@ -202,6 +203,7 @@ private IPackTaskRequest<IMSBuildItem> GetRequest()
PackageLicenseExpression = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageLicenseExpression),
PackageLicenseFile = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageLicenseFile),
PackageLicenseExpressionVersion = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageLicenseExpressionVersion),
Readme = MSBuildStringUtility.TrimAndGetNullForEmpty(Readme),
Deterministic = Deterministic,
PackageIcon = MSBuildStringUtility.TrimAndGetNullForEmpty(PackageIcon),
};
Expand Down
2 changes: 2 additions & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ public PackageBuilder GetPackageBuilder(IPackTaskRequest<IMSBuildItem> request)

builder.Icon = request.PackageIcon;

builder.Readme = request.Readme;

if (request.MinClientVersion != null)
{
Version version;
Expand Down
1 change: 1 addition & 0 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class PackTaskRequest : IPackTaskRequest<IMSBuildItem>
public string NuspecBasePath { get; set; }
public string[] NuspecProperties { get; set; }
public bool OutputFileNamesWithoutVersion { get; set; }
public string Readme { get; set; }
public string ReleaseNotes { get; set; }
public string RepositoryType { get; set; }
public string RepositoryUrl { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NuGet.Build.Tasks.Pack.IPackTaskRequest<TItem>.Readme.get -> string
NuGet.Build.Tasks.Pack.PackTask.Readme.get -> string
NuGet.Build.Tasks.Pack.PackTask.Readme.set -> void
NuGet.Build.Tasks.Pack.PackTaskRequest.Readme.get -> string
NuGet.Build.Tasks.Pack.PackTaskRequest.Readme.set -> void
24 changes: 22 additions & 2 deletions src/NuGet.Core/NuGet.Common/Errors/NuGetLogCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace NuGet.Common
/// <para>
/// Format - NUxyzw where NU is the prefix indicating NuGet and xyzw is a 4 digit code
/// </para>
///
///
/// Numbers - xyzw
/// x - 'x' is the largest digit and should be used to quantify a set of errors.
/// For example 1yzw are set of restore related errors and no other code path should use the range 1000 to 1999 for errors or warnings.
Expand All @@ -22,7 +22,7 @@ namespace NuGet.Common
///
/// zw - 'zw' are the least two digit.
/// These could be used for different errors or warnings within the broad categories set by digits 'xy'.
///
///
/// <para>
/// Groups:
/// 1000-1999 - Restore
Expand Down Expand Up @@ -692,6 +692,26 @@ public enum NuGetLogCode
/// </summary>
NU5037 = 5037,

/// <summary>
/// Error_ReadmeFileExtensionIsInvalid
/// </summary>
NU5038 = 5038,

/// <summary>
/// Error_ReadmeNoFileElement
/// </summary>
NU5039 = 5039,

/// <summary>
/// Error_ReadmeErrorEmpty
/// </summary>
NU5040 = 5040,

/// <summary>
/// Error_ReadmeCannotOpenFile
/// </summary>
NU5041 = 5041,

/// <summary>
/// Invalid icon extension error
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
NuGet.Common.NuGetLogCode.NU5050 = 5050 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5132 = 5132 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5038 = 5038 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5039 = 5039 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5040 = 5040 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5041 = 5041 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
NuGet.Common.NuGetLogCode.NU5050 = 5050 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5132 = 5132 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5038 = 5038 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5039 = 5039 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5040 = 5040 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5041 = 5041 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
NuGet.Common.NuGetLogCode.NU5050 = 5050 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5132 = 5132 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5038 = 5038 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5039 = 5039 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5040 = 5040 -> NuGet.Common.NuGetLogCode
NuGet.Common.NuGetLogCode.NU5041 = 5041 -> NuGet.Common.NuGetLogCode
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static class NuGetConstants
public static readonly string SymbolsExtension = ".symbols" + PackageExtension;
public static readonly string ManifestExtension = ".nuspec";
public static readonly string ManifestSymbolsExtension = ".symbols" + ManifestExtension;
public static readonly string ReadmeExtension = ".md";
public static readonly string PackageReferenceFile = "packages.config";
public static readonly string PackageSpecFileName = "project.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static readonly NuGet.Configuration.NuGetConstants.ReadmeExtension -> string
Loading