Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Use correct nuget version normalized format #9525

Merged
merged 2 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotnet/ToolPackage/ToolPackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private FilePath CreateTempProject(PackageId packageId,
new XElement("PackageReference",
new XAttribute("Include", packageId.ToString()),
new XAttribute("Version",
versionRange?.ToString("S", new VersionRangeFormatter()) ?? "*"))), // nuget will restore latest stable for *
versionRange?.ToString("N", new VersionRangeFormatter()) ?? "*"))), // nuget will restore latest stable for * and format N is the normalization format
new XElement(("Import"),
new XAttribute("Project", "Sdk.targets"),
new XAttribute("Sdk", "Microsoft.NET.Sdk"))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public void GivenANuGetDiagnosticMessageItShouldNotContainTheTempProject()

var package = installer.InstallPackage(
packageId: TestPackageId,
versionRange: VersionRange.Parse("1.0.*"),
versionRange: VersionRange.Parse("1.0.0"),
targetFramework: _testTargetframework,
nugetConfig: nugetConfigPath);

Expand All @@ -612,6 +612,31 @@ public void GivenANuGetDiagnosticMessageItShouldNotContainTheTempProject()
package.Uninstall();
}

[Theory]
[InlineData(false)]
[InlineData(true)]
// repro https://github.com/dotnet/cli/issues/9409
public void GivenAComplexVersionRangeInstallSucceeds(bool testMockBehaviorIsInSync)
{
var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed();
var emptySource = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(emptySource);

var (store, installer, reporter, fileSystem) = Setup(
useMock: testMockBehaviorIsInSync,
feeds: GetMockFeedsForSource(emptySource));

var package = installer.InstallPackage(
packageId: TestPackageId,
versionRange: VersionRange.Parse("1.0.0-rc*"),
targetFramework: _testTargetframework,
nugetConfig: nugetConfigPath, additionalFeeds: new[] { emptySource });

AssertPackageInstall(reporter, fileSystem, package, store);

package.Uninstall();
}

private static void AssertPackageInstall(
BufferedReporter reporter,
IFileSystem fileSystem,
Expand Down