Skip to content

Commit

Permalink
Use min of version range for Project K dependencies (matches UWP proj…
Browse files Browse the repository at this point in the history
…ect.json)

Fixes NuGet/Home#3070
Fixes NuGet/Home#3095
  • Loading branch information
joelverhagen committed Jul 11, 2016
1 parent eb89a13 commit 78476ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ public override async Task<IEnumerable<PackageReference>> GetInstalledPackagesAs
var moniker = item as INuGetPackageMoniker;
if (moniker != null)
{
identity = new PackageIdentity(
moniker.Id,
NuGetVersion.Parse(moniker.Version));
// As with build integrated projects (UWP project.json), treat the version as a
// version range and use the minimum version of that range. Eventually, this
// method should return VersionRange instances, not NuGetVersion so that the
// UI can express the full project.json intent. This improvement is tracked
// here: https://github.com/NuGet/Home/issues/3101
var versionRange = VersionRange.Parse(moniker.Version);
var version = versionRange.MinVersion;

identity = new PackageIdentity(moniker.Id, version);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ namespace NuGet.PackageManagement.VisualStudio.Test
{
public class ProjectKNuGetProjectTests
{
[Fact]
public async Task ProjectKNuGetProject_WithVersionRange_GetInstalledPackagesAsync()
{
// Arrange
using (var testDirectory = TestFileSystemUtility.CreateRandomTestFolder())
{
var tc = new TestContext(testDirectory);

tc.PackageManager
.Setup(x => x.GetInstalledPackagesAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(new[] { new NuGetPackageMoniker { Id = "foo", Version = "1.0.0-*" } });

// Act
var actual = await tc.Target.GetInstalledPackagesAsync(CancellationToken.None);

// Assert
Assert.Equal(1, actual.Count());
var packageReference = actual.First();
Assert.Equal("foo", packageReference.PackageIdentity.Id);
Assert.Equal(NuGetVersion.Parse("1.0.0--"), packageReference.PackageIdentity.Version);
}
}

[Fact]
public async Task ProjectKNuGetProject_WithPackageTypes_InstallPackageAsync()
{
Expand Down

0 comments on commit 78476ce

Please sign in to comment.