Merge pull request #5302 from livarcocc/fix_migration_dropping_dependencies
Fixing an issue where packages with a filter but no match were being dropped
This commit is contained in:
commit
c868faf034
2 changed files with 23 additions and 13 deletions
|
@ -291,21 +291,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
|
||||||
{
|
{
|
||||||
var possibleVersions = possibleMappings.Select(p => VersionRange.Parse(p.Key.Version));
|
var possibleVersions = possibleMappings.Select(p => VersionRange.Parse(p.Key.Version));
|
||||||
var matchVersion = possibleVersions.FirstOrDefault(p => p.Satisfies(minRange));
|
var matchVersion = possibleVersions.FirstOrDefault(p => p.Satisfies(minRange));
|
||||||
if (matchVersion == null)
|
if (matchVersion != null)
|
||||||
{
|
{
|
||||||
return null;
|
var dependencyInfo = possibleMappings.First(c =>
|
||||||
|
c.Key.Version.Equals(matchVersion.OriginalString, StringComparison.OrdinalIgnoreCase)).Value;
|
||||||
|
|
||||||
|
if (dependencyInfo == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = dependencyInfo.Name;
|
||||||
|
version = dependencyInfo.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dependencyInfo = possibleMappings.First(c =>
|
|
||||||
c.Key.Version.Equals(matchVersion.OriginalString, StringComparison.OrdinalIgnoreCase)).Value;
|
|
||||||
|
|
||||||
if (dependencyInfo == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = dependencyInfo.Name;
|
|
||||||
version = dependencyInfo.Version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PackageDependencyInfo
|
return new PackageDependencyInfo
|
||||||
|
|
|
@ -24,6 +24,18 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
||||||
ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion);
|
ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("NETStandard.Library", "1.6.2-*", "NETStandard.Library", "1.6.2-*")]
|
||||||
|
[InlineData("System.Text.Encodings.Web", "4.4.0-*", "System.Text.Encodings.Web", "4.4.0-*")]
|
||||||
|
public void ItDoesNotDropDependenciesThatDoNotHaveAMatchingVersionInTheMapping(
|
||||||
|
string sourcePackageName,
|
||||||
|
string sourceVersion,
|
||||||
|
string targetPackageName,
|
||||||
|
string targetVersion)
|
||||||
|
{
|
||||||
|
ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion);
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Microsoft.AspNetCore.Antiforgery", "1.0.0", "Microsoft.AspNetCore.Antiforgery", ConstantPackageVersions.AspNetLTSPackagesVersion)]
|
[InlineData("Microsoft.AspNetCore.Antiforgery", "1.0.0", "Microsoft.AspNetCore.Antiforgery", ConstantPackageVersions.AspNetLTSPackagesVersion)]
|
||||||
[InlineData("Microsoft.AspNetCore.Mvc", "1.0.0", "Microsoft.AspNetCore.Mvc", ConstantPackageVersions.AspNetLTSPackagesVersion)]
|
[InlineData("Microsoft.AspNetCore.Mvc", "1.0.0", "Microsoft.AspNetCore.Mvc", ConstantPackageVersions.AspNetLTSPackagesVersion)]
|
||||||
|
|
Loading…
Reference in a new issue