Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrrm committed Sep 28, 2022
1 parent 0aac0f7 commit 3adfc12
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ public bool AreCentralVersionRequirementsSatisfied(PackageReferenceArgs packageR
string directoryPackagesPropsPath = project.GetPropertyValue(DirectoryPackagesPropsPathPropertyName);

// Get VersionOverride if it exisits in the package reference.
IEnumerable<LibraryDependency> dependenciesWithVersionOverride = packageSpec.TargetFrameworks.SelectMany(tfm => tfm.Dependencies.Where(d => !d.AutoReferenced && d.VersionOverride != null));
IEnumerable<LibraryDependency> dependenciesWithVersionOverride = null;

if (packageSpec.RestoreMetadata.CentralPackageVersionOverrideDisabled)
{
dependenciesWithVersionOverride = packageSpec.TargetFrameworks.SelectMany(tfm => tfm.Dependencies.Where(d => !d.AutoReferenced && d.VersionOverride != null));
// Emit a error if VersionOverride was specified for a package reference but that functionality is disabled
foreach (var item in dependenciesWithVersionOverride)
{
Expand Down Expand Up @@ -188,7 +189,7 @@ public bool AreCentralVersionRequirementsSatisfied(PackageReferenceArgs packageR

ProjectItem packageReference = project.Items.Where(item => item.ItemType == PACKAGE_REFERENCE_TYPE_TAG && item.EvaluatedInclude.Equals(packageReferenceArgs.PackageId)).LastOrDefault();
ProjectItem packageVersionInProps = packageVersions.LastOrDefault();
var versionOverride = dependenciesWithVersionOverride.FirstOrDefault(d => d.Name.Equals(packageReferenceArgs.PackageId));
var versionOverride = dependenciesWithVersionOverride?.FirstOrDefault(d => d.Name.Equals(packageReferenceArgs.PackageId));

// If package reference exists and the user defined a VersionOverride or PackageVersions but didn't specified a version, no-op
if (packageReference != null && (versionOverride != null || packageVersionInProps != null) && packageReferenceArgs.NoVersion)
Expand Down

0 comments on commit 3adfc12

Please sign in to comment.