From 1a2ba29afa0db342adb933dd740fb06c0ca6961a Mon Sep 17 00:00:00 2001 From: Anipik Date: Fri, 7 May 2021 14:53:32 -0700 Subject: [PATCH] packageId --- .../GetCompatiblePackageTargetFrameworks.cs | 7 +++---- src/Microsoft.DotNet.PackageValidation/NupkgParser.cs | 6 +++--- src/Microsoft.DotNet.PackageValidation/Package.cs | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.DotNet.PackageValidation/GetCompatiblePackageTargetFrameworks.cs b/src/Microsoft.DotNet.PackageValidation/GetCompatiblePackageTargetFrameworks.cs index 4a8bc4377ea..9f877db7bc0 100644 --- a/src/Microsoft.DotNet.PackageValidation/GetCompatiblePackageTargetFrameworks.cs +++ b/src/Microsoft.DotNet.PackageValidation/GetCompatiblePackageTargetFrameworks.cs @@ -26,7 +26,6 @@ public override bool Execute() { bool result = true; List testProjects = new List(); - try { Initialize(); @@ -36,7 +35,7 @@ public override bool Execute() List packageTargetFrameworks = package.PackageAssets.Where(t => t.AssetType != AssetType.RuntimeAsset).Select(t => t.TargetFramework).Distinct().ToList(); List frameworksToTest = GetTestFrameworks(packageTargetFrameworks); - testProjects.AddRange(CreateItemFromTestFramework(package.Title, package.Version, frameworksToTest, GetRidsFromPackage(package))); + testProjects.AddRange(CreateItemFromTestFramework(package.PackageId, package.Version, frameworksToTest, GetRidsFromPackage(package))); } // Removing empty items. @@ -113,12 +112,12 @@ public static void Initialize() } } - public List CreateItemFromTestFramework(string title, string version, List testFrameworks, string rids) + public List CreateItemFromTestFramework(string packageId, string version, List testFrameworks, string rids) { List testprojects = new List(); foreach (var framework in testFrameworks) { - var supportedPackage = new TaskItem(title); + var supportedPackage = new TaskItem(packageId); supportedPackage.SetMetadata("Version", version); supportedPackage.SetMetadata("TargetFramework", framework.ToString()); supportedPackage.SetMetadata("TargetFrameworkShort", framework.GetShortFolderName()); diff --git a/src/Microsoft.DotNet.PackageValidation/NupkgParser.cs b/src/Microsoft.DotNet.PackageValidation/NupkgParser.cs index 77d73bb0c69..ed328a8947e 100644 --- a/src/Microsoft.DotNet.PackageValidation/NupkgParser.cs +++ b/src/Microsoft.DotNet.PackageValidation/NupkgParser.cs @@ -19,7 +19,7 @@ public static Package CreatePackageObject(string packagePath) PackageArchiveReader nupkgReader = new PackageArchiveReader(packagePath); NuspecReader nuspecReader = nupkgReader.NuspecReader; - string title = nuspecReader.GetTitle(); + string packageId = nuspecReader.GetId(); string version = nuspecReader.GetVersion().ToString(); IEnumerable dependencyGroups = nuspecReader.GetDependencyGroups(); @@ -28,13 +28,13 @@ public static Package CreatePackageObject(string packagePath) packageDependencies.Add(item.TargetFramework, item.Packages.ToList()); } - var files = nupkgReader.GetFiles().ToList().Where(t => t.EndsWith(".dll")).Where(t => t.Contains(title + ".dll")); + var files = nupkgReader.GetFiles().ToList().Where(t => t.EndsWith(".dll")).Where(t => t.Contains(packageId + ".dll")); foreach (var file in files) { packageAssets.Add(ExtractAssetFromFile(file)); } - return new Package(title, version, packageAssets, packageDependencies); + return new Package(packageId, version, packageAssets, packageDependencies); } public static PackageAsset ExtractAssetFromFile(string filePath) diff --git a/src/Microsoft.DotNet.PackageValidation/Package.cs b/src/Microsoft.DotNet.PackageValidation/Package.cs index c24624de1dd..e4d30d724f9 100644 --- a/src/Microsoft.DotNet.PackageValidation/Package.cs +++ b/src/Microsoft.DotNet.PackageValidation/Package.cs @@ -10,12 +10,12 @@ namespace Microsoft.DotNet.PackageValidation public class Package { public List PackageAssets { get; set; } - public string Title { get; set; } + public string PackageId { get; set; } public string Version { get; set; } public Dictionary> PackageDependencies { get; set; } - public Package(string title, string version, List packageAssets, Dictionary> packageDependencies) + public Package(string packageId, string version, List packageAssets, Dictionary> packageDependencies) { - Title = title; + PackageId = packageId; Version = version; PackageAssets = packageAssets; PackageDependencies = packageDependencies;