Skip to content

Commit

Permalink
Fix empty combobox when package is not present in project file (#4844)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrrm authored Oct 6, 2022
1 parent f4e0ae1 commit d8a2220
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ protected void AddBlockedVersions(List<NuGetVersion> blockedVersions)
// add all the versions blocked to disable the update button
foreach (var version in blockedVersions)
{
_versions.Add(new DisplayVersion(version, string.Empty, isValidVersion: false));
_versions.Add(new DisplayVersion(version, additionalInfo: null, isValidVersion: false));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected override Task CreateVersionsAsync(CancellationToken cancellationToken)
var latestStableVersion = allVersionsAllowed.FirstOrDefault(v => !v.version.IsPrerelease);

// Add installed version if the project is PackageReference
if (_nugetProjects.Any() && installedDependency != null && installedDependency.VersionRange != null && _nugetProjects.First().ProjectStyle.Equals(ProjectModel.ProjectStyle.PackageReference))
if (_nugetProjects.Any() && installedDependency != null && installedDependency.VersionRange.OriginalString != null && _nugetProjects.First().ProjectStyle.Equals(ProjectModel.ProjectStyle.PackageReference))
{
VersionRange installedVersionRange = VersionRange.Parse(installedDependency.VersionRange.OriginalString, true);
NuGetVersion bestVersion = installedVersionRange.FindBestMatch(allVersionsAllowed.Select(v => v.version));
Expand Down Expand Up @@ -311,6 +311,7 @@ public override void OnSelectedVersionChanged()
OnPropertyChanged(nameof(IsInstalledVersionTopLevel));
}


public bool IsSelectedVersionInstalled
{
get
Expand All @@ -326,7 +327,7 @@ public bool IsInstallorUpdateButtonEnabled
{
get
{
return SelectedVersion != null && !IsSelectedVersionInstalled;
return SelectedVersion != null && !IsSelectedVersionInstalled && !InstalledVersionIsAutoReferenced;
}
}

Expand Down

0 comments on commit d8a2220

Please sign in to comment.