From b9c4bc532fba01a5310c16cdb3c80ef6c4b62d8c Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 21 Mar 2017 16:58:41 -0500 Subject: [PATCH] (GH-12) add software display name / version Add fields based on the registry name for software being installed to make it easier to evaluate what is being created. This facilitates the ability to know ahead of time what is being added to the registry and what version it shows. --- src/Core/Authoring/Manifest.cs | 2 ++ src/Core/Authoring/ManifestMetadata.cs | 7 ++++++- src/Core/Authoring/ManifestReader.cs | 6 ++++++ src/Core/Authoring/PackageBuilder.cs | 8 +++++++- src/Core/Authoring/nuspec.xsd | 2 ++ src/Core/Packages/DataServicePackage.cs | 3 +++ src/Core/Packages/IChocolateyPackageMetadata.cs | 3 +++ src/Core/Packages/LocalPackage.cs | 3 +++ src/Server/DataServices/Package.cs | 6 ++++++ test/Server.Test/FeedPackageTest.cs | 2 +- test/Test.Utility/PackageUtility.cs | 2 ++ 11 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Core/Authoring/Manifest.cs b/src/Core/Authoring/Manifest.cs index 8523f8211..7b6f3934e 100644 --- a/src/Core/Authoring/Manifest.cs +++ b/src/Core/Authoring/Manifest.cs @@ -158,6 +158,8 @@ private static Manifest CreateManifestWithMetadata(IPackageMetadata metadata) Replaces = GetCommaSeparatedString(metadata.Replaces), Provides = GetCommaSeparatedString(metadata.Provides), Conflicts = GetCommaSeparatedString(metadata.Conflicts), + SoftwareDisplayName = metadata.SoftwareDisplayName.SafeTrim(), + SoftwareDisplayVersion = metadata.SoftwareDisplayVersion.SafeTrim(), IconUrl = ConvertUrlToStringSafe(metadata.IconUrl), RequireLicenseAcceptance = metadata.RequireLicenseAcceptance, DevelopmentDependency = metadata.DevelopmentDependency, diff --git a/src/Core/Authoring/ManifestMetadata.cs b/src/Core/Authoring/ManifestMetadata.cs index af17cf3aa..10a62d3ba 100644 --- a/src/Core/Authoring/ManifestMetadata.cs +++ b/src/Core/Authoring/ManifestMetadata.cs @@ -107,6 +107,12 @@ public string Owners [XmlElement("tags")] public string Tags { get; set; } + [XmlElement("softwareDisplayName")] + public string SoftwareDisplayName { get; set; } + + [XmlElement("softwareDisplayVersion")] + public string SoftwareDisplayVersion { get; set; } + [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Xml deserialziation can't handle uris")] [XmlElement("projectSourceUrl")] public string ProjectSourceUrl { get; set; } @@ -617,6 +623,5 @@ private static PackageDependencySet CreatePackageDependencySet(ManifestDependenc return new PackageDependencySet(targetFramework, dependencies); } - } } \ No newline at end of file diff --git a/src/Core/Authoring/ManifestReader.cs b/src/Core/Authoring/ManifestReader.cs index 567072c05..f021adfa7 100644 --- a/src/Core/Authoring/ManifestReader.cs +++ b/src/Core/Authoring/ManifestReader.cs @@ -151,6 +151,12 @@ private static void ReadMetadataValue(ManifestMetadata manifestMetadata, XElemen break; case "conflicts": manifestMetadata.Conflicts = value; + break; + case "softwareDisplayName": + manifestMetadata.SoftwareDisplayName = value; + break; + case "softwareDisplayVersion": + manifestMetadata.SoftwareDisplayVersion = value; break; case "dependencies": manifestMetadata.DependencySets = ReadDependencySets(element); diff --git a/src/Core/Authoring/PackageBuilder.cs b/src/Core/Authoring/PackageBuilder.cs index f9c49eb83..52af340f4 100644 --- a/src/Core/Authoring/PackageBuilder.cs +++ b/src/Core/Authoring/PackageBuilder.cs @@ -162,6 +162,9 @@ public ISet Tags public ISet Provides { get; set; } public ISet Conflicts { get; set; } + public string SoftwareDisplayName { get; set; } + public string SoftwareDisplayVersion { get; set; } + public string Copyright { get; @@ -491,7 +494,10 @@ public void Populate(ManifestMetadata manifestMetadata) Replaces.AddRange(metadata.Replaces); Provides.AddRange(metadata.Provides); Conflicts.AddRange(metadata.Conflicts); - + + SoftwareDisplayName = metadata.SoftwareDisplayName; + SoftwareDisplayVersion = metadata.SoftwareDisplayVersion; + if (metadata.Tags != null) { Tags.AddRange(ParseTags(metadata.Tags)); diff --git a/src/Core/Authoring/nuspec.xsd b/src/Core/Authoring/nuspec.xsd index 12ec8e9d7..29cc33be8 100644 --- a/src/Core/Authoring/nuspec.xsd +++ b/src/Core/Authoring/nuspec.xsd @@ -63,6 +63,8 @@ + + diff --git a/src/Core/Packages/DataServicePackage.cs b/src/Core/Packages/DataServicePackage.cs index 4770e7954..819f0d7de 100644 --- a/src/Core/Packages/DataServicePackage.cs +++ b/src/Core/Packages/DataServicePackage.cs @@ -245,6 +245,9 @@ public string Dependencies public bool IsDownloadCacheAvailable { get; set; } public DateTime? DownloadCacheDate { get; set; } public string DownloadCache { get; set; } + + public string SoftwareDisplayName { get; set; } + public string SoftwareDisplayVersion { get; set; } IEnumerable IServerPackageMetadata.DownloadCache { diff --git a/src/Core/Packages/IChocolateyPackageMetadata.cs b/src/Core/Packages/IChocolateyPackageMetadata.cs index 1b87c75d2..b819df3b4 100644 --- a/src/Core/Packages/IChocolateyPackageMetadata.cs +++ b/src/Core/Packages/IChocolateyPackageMetadata.cs @@ -14,5 +14,8 @@ public partial interface IPackageMetadata IEnumerable Replaces { get; } IEnumerable Provides { get; } IEnumerable Conflicts { get; } + + string SoftwareDisplayName { get; } + string SoftwareDisplayVersion { get; } } } \ No newline at end of file diff --git a/src/Core/Packages/LocalPackage.cs b/src/Core/Packages/LocalPackage.cs index bd205fb99..bb315696d 100644 --- a/src/Core/Packages/LocalPackage.cs +++ b/src/Core/Packages/LocalPackage.cs @@ -117,6 +117,9 @@ public string Tags public IEnumerable Provides { get; set; } public IEnumerable Conflicts { get; set; } + public string SoftwareDisplayName { get; set; } + public string SoftwareDisplayVersion { get; set; } + public Version MinClientVersion { get; diff --git a/src/Server/DataServices/Package.cs b/src/Server/DataServices/Package.cs index 52bcf2293..9cd8b16a4 100644 --- a/src/Server/DataServices/Package.cs +++ b/src/Server/DataServices/Package.cs @@ -102,6 +102,9 @@ public Package(IPackage package, DerivedPackageData derivedData) IsDownloadCacheAvailable = package.IsDownloadCacheAvailable; DownloadCacheDate = package.DownloadCacheDate; DownloadCache = String.Join("|", package.DownloadCache.Select(ConvertDownloadCacheToStrings)); + + SoftwareDisplayName = package.SoftwareDisplayName; + SoftwareDisplayVersion = package.SoftwareDisplayVersion; } internal string FullPath @@ -294,6 +297,9 @@ public string MinClientVersion public string Replaces { get; set; } public string Provides { get; set; } public string Conflicts { get; set; } + // round 2 + public string SoftwareDisplayName { get; set; } + public string SoftwareDisplayVersion { get; set; } #endregion #region Server Metadata Only diff --git a/test/Server.Test/FeedPackageTest.cs b/test/Server.Test/FeedPackageTest.cs index d06a468db..097ed8566 100644 --- a/test/Server.Test/FeedPackageTest.cs +++ b/test/Server.Test/FeedPackageTest.cs @@ -19,7 +19,7 @@ public void FeedPackageHasSameMembersAsDataServicePackage() var excludedProperties = new[] { "Owners", "ReportAbuseUrl", "GalleryDetailsUrl", "DownloadUrl", "Rating", "RatingsCount", "Language", "AssemblyReferences", "FrameworkAssemblies", "DependencySets", "PackageAssemblyReferences", "LicenseNames", "LicenseNameCollection", "LicenseReportUrl", "ProjectSourceUrl", "PackageSourceUrl","DocsUrl","WikiUrl", - "MailingListUrl","BugTrackerUrl","Replaces", "Provides", "Conflicts" + "MailingListUrl","BugTrackerUrl","Replaces", "Provides", "Conflicts", "SoftwareDisplayName", "SoftwareDisplayVersion" }; var feedPackageProperties = new HashSet(typeof(NuGet.Server.DataServices.Package).GetProperties().Select(p => p.Name), StringComparer.Ordinal); var dataServiceProperties = typeof(DataServicePackage).GetProperties() diff --git a/test/Test.Utility/PackageUtility.cs b/test/Test.Utility/PackageUtility.cs index b108510f9..7daf930e2 100644 --- a/test/Test.Utility/PackageUtility.cs +++ b/test/Test.Utility/PackageUtility.cs @@ -215,6 +215,8 @@ public static IPackage CreatePackage(string id, mockPackage.Setup(m => m.Replaces).Returns(new[] { String.Empty }); mockPackage.Setup(m => m.Provides).Returns(new[] { String.Empty }); mockPackage.Setup(m => m.Conflicts).Returns(new[] { String.Empty }); + mockPackage.Setup(m => m.SoftwareDisplayName).Returns(String.Empty); + mockPackage.Setup(m => m.SoftwareDisplayVersion).Returns(String.Empty); mockPackage.Setup(m => m.MinClientVersion).Returns(minClientVersion == null ? new Version() : Version.Parse(minClientVersion)); mockPackage.Setup(m => m.PackageAssemblyReferences).Returns(new PackageReferenceSet[0]); if (!listed)