Skip to content

Commit

Permalink
packageId (#7360)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anipik authored May 8, 2021
1 parent c2b5f4c commit 5faea1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public override bool Execute()
{
bool result = true;
List<ITaskItem> testProjects = new List<ITaskItem>();

try
{
Initialize();
Expand All @@ -36,7 +35,7 @@ public override bool Execute()
List<NuGetFramework> packageTargetFrameworks = package.PackageAssets.Where(t => t.AssetType != AssetType.RuntimeAsset).Select(t => t.TargetFramework).Distinct().ToList();

List<NuGetFramework> 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.
Expand Down Expand Up @@ -113,12 +112,12 @@ public static void Initialize()
}
}

public List<ITaskItem> CreateItemFromTestFramework(string title, string version, List<NuGetFramework> testFrameworks, string rids)
public List<ITaskItem> CreateItemFromTestFramework(string packageId, string version, List<NuGetFramework> testFrameworks, string rids)
{
List<ITaskItem> testprojects = new List<ITaskItem>();
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());
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.DotNet.PackageValidation/NupkgParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackageDependencyGroup> dependencyGroups = nuspecReader.GetDependencyGroups();

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.DotNet.PackageValidation/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace Microsoft.DotNet.PackageValidation
public class Package
{
public List<PackageAsset> PackageAssets { get; set; }
public string Title { get; set; }
public string PackageId { get; set; }
public string Version { get; set; }
public Dictionary<NuGetFramework, List<PackageDependency>> PackageDependencies { get; set; }
public Package(string title, string version, List<PackageAsset> packageAssets, Dictionary<NuGetFramework, List<PackageDependency>> packageDependencies)
public Package(string packageId, string version, List<PackageAsset> packageAssets, Dictionary<NuGetFramework, List<PackageDependency>> packageDependencies)
{
Title = title;
PackageId = packageId;
Version = version;
PackageAssets = packageAssets;
PackageDependencies = packageDependencies;
Expand Down

0 comments on commit 5faea1b

Please sign in to comment.