Use correct nuget version normalized format (#9525)
* Use correct nuget version normalized format * Change test accordingly This matches nuget behavior if restore with `<PackageReference Include="global.tool.console.demo" Version="1.0.*" />` there is no warning and if restore with `<PackageReference Include="global.tool.console.demo" Version="1.0.0" />` there is warning due to no exact 1.0.0 find
This commit is contained in:
parent
4757e52adb
commit
488edfad3f
2 changed files with 27 additions and 2 deletions
|
@ -154,7 +154,7 @@ namespace Microsoft.DotNet.ToolPackage
|
|||
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"))));
|
||||
|
|
|
@ -598,7 +598,7 @@ namespace Microsoft.DotNet.ToolPackage.Tests
|
|||
|
||||
var package = installer.InstallPackage(
|
||||
packageId: TestPackageId,
|
||||
versionRange: VersionRange.Parse("1.0.*"),
|
||||
versionRange: VersionRange.Parse("1.0.0"),
|
||||
targetFramework: _testTargetframework,
|
||||
nugetConfig: nugetConfigPath);
|
||||
|
||||
|
@ -612,6 +612,31 @@ namespace Microsoft.DotNet.ToolPackage.Tests
|
|||
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,
|
||||
|
|
Loading…
Reference in a new issue