diff options
author | Tom Meschter <tom.meschter@valinor.org> | 2017-10-05 02:00:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-05 02:00:59 +0300 |
commit | 8316e6a9ffcec0c0f8ae6a99f1f39bac5417b4e3 (patch) | |
tree | b37e0a876588d0597ca745abe6a655f77da11d26 | |
parent | 4143dafdadaf412dd947482ed6109ea800d88cec (diff) | |
parent | 84388f19c4b8206fef2c1393cf2f799994e8e515 (diff) |
Merge pull request #40 from tmeschter/IgnoreCaseWhenComparingPackageNames
Ignore case when comparing package names
11 files changed, 229 insertions, 15 deletions
diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs index f0345cb..e75ea94 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Json { @@ -152,7 +152,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// "version": 2, /// "targets": { /// ".NETFramework,Version=v4.5": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "type": "package", /// "compile": { /// "lib/net45/Newtonsoft.Json.dll": {} @@ -164,7 +164,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// } /// }, /// "libraries": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", /// "type": " [rest of string was truncated]";. /// </summary> @@ -180,7 +180,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// "version": 2, /// "targets": { /// ".NETFramework,Version=v4.5": { - /// "Newtonsoft.Json/8.0.3": { + /// "Newtonsoft.Json/9.0.1": { /// "type": "package", /// "compile": { /// "lib/net45/Newtonsoft.Json.dll": {} @@ -207,6 +207,36 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json { /// <summary> /// Looks up a localized string similar to { /// "locked": false, + /// "version": 2, + /// "targets": { + /// ".NETFramework,Version=v4.5": { + /// "Newtonsoft.Json/9.0.1": { + /// "type": "package", + /// "compile": { + /// "lib/net45/Newtonsoft.Json.dll": {} + /// }, + /// "runtime": { + /// "lib/net45/Newtonsoft.Json.dll": {} + /// } + /// } + /// }, + /// ".NETFramework,Version=v4.6": { + /// "FluentAssertions/3.4.1": { + /// "frameworkAssemblies": [ + /// "System.Xml", + /// "System.Xml.Linq" + /// ], + /// [rest of string was truncated]";. + /// </summary> + internal static string MultipleProjectFileDependencyGroups_CaseMismatch { + get { + return ResourceManager.GetString("MultipleProjectFileDependencyGroups_CaseMismatch", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to { + /// "locked": false, /// "version": 1, /// "targets": { /// ".NETCore,Version=v5.0": { diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx index a59102f..993a1fe 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx @@ -148,4 +148,7 @@ <data name="ProjectDependency" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>ProjectDependency.assets.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> </data> + <data name="MultipleProjectFileDependencyGroups_CaseMismatch" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>multipleprojectfiledependencygroups_casemismatch.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> + </data> </root>
\ No newline at end of file diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json index b523b70..b529b16 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/LockFileWithWithSpecifiedPackageFolders.json @@ -18,7 +18,7 @@ "Newtonsoft.Json/9.0.1": { "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", "type": "package", - "path": "newtonsoft.json/current", + "path": "newtonsoft.json/9.0.1", "files": [ "lib/net20/Newtonsoft.Json.dll", "lib/net20/Newtonsoft.Json.xml", diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json index 1c1f2df..a14ad6d 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups.json @@ -34,7 +34,7 @@ "Newtonsoft.Json/9.0.1": { "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", "type": "package", - "path": "newtonsoft.json/current", + "path": "newtonsoft.json/9.0.1", "files": [ "lib/net20/Newtonsoft.Json.dll", "lib/net20/Newtonsoft.Json.xml", diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json new file mode 100644 index 0000000..11c6892 --- /dev/null +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json @@ -0,0 +1,150 @@ +{ + "locked": false, + "version": 2, + "targets": { + ".NETFramework,Version=v4.5": { + "Newtonsoft.Json/9.0.1": { + "type": "package", + "compile": { + "lib/net45/Newtonsoft.Json.dll": {} + }, + "runtime": { + "lib/net45/Newtonsoft.Json.dll": {} + } + } + }, + ".NETFramework,Version=v4.6": { + "FluentAssertions/3.4.1": { + "frameworkAssemblies": [ + "System.Xml", + "System.Xml.Linq" + ], + "compile": { + "lib/net45/FluentAssertions.Core.dll": {}, + "lib/net45/FluentAssertions.dll": {} + }, + "runtime": { + "lib/net45/FluentAssertions.Core.dll": {}, + "lib/net45/FluentAssertions.dll": {} + } + } + } + }, + "libraries": { + "Newtonsoft.Json/9.0.1": { + "sha512": "KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==", + "type": "package", + "path": "newtonsoft.json/9.0.1", + "files": [ + "lib/net20/Newtonsoft.Json.dll", + "lib/net20/Newtonsoft.Json.xml", + "lib/net35/Newtonsoft.Json.dll", + "lib/net35/Newtonsoft.Json.xml", + "lib/net40/Newtonsoft.Json.dll", + "lib/net40/Newtonsoft.Json.xml", + "lib/net45/Newtonsoft.Json.dll", + "lib/net45/Newtonsoft.Json.xml", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll", + "lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml", + "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.dll", + "lib/portable-net45+wp80+win8+wpa81+dnxcore50/Newtonsoft.Json.xml", + "newtonsoft.json.9.0.1.nupkg.sha512", + "newtonsoft.json.nuspec", + "tools/install.ps1" + ] + }, + "FluentAssertions/3.4.1": { + "sha512": "GTyLzP7d57D3HLVOSFrTSVwod3rZNQRMC2DR13u1hNNyhsskLrbI4SW5XXqyEv8WP7v8IqWx9hdlDiwLY0G8YA==", + "type": "Package", + "files": [ + "_rels/.rels", + "FluentAssertions.nuspec", + "lib/net40/FluentAssertions.Core.dll", + "lib/net40/FluentAssertions.Core.pdb", + "lib/net40/FluentAssertions.Core.xml", + "lib/net40/FluentAssertions.dll", + "lib/net40/FluentAssertions.pdb", + "lib/net40/FluentAssertions.xml", + "lib/net45/FluentAssertions.Core.dll", + "lib/net45/FluentAssertions.Core.pdb", + "lib/net45/FluentAssertions.Core.xml", + "lib/net45/FluentAssertions.dll", + "lib/net45/FluentAssertions.pdb", + "lib/net45/FluentAssertions.xml", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.dll", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.pdb", + "lib/portable-monotouch+monoandroid+xamarin.ios/FluentAssertions.Core.xml", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.dll", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.pdb", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.Core.xml", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.dll", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.pdb", + "lib/portable-net40+sl5+win8+wp8+wpa81/FluentAssertions.XML", + "lib/portable-win81+wpa81/FluentAssertions.Core.dll", + "lib/portable-win81+wpa81/FluentAssertions.Core.pdb", + "lib/portable-win81+wpa81/FluentAssertions.Core.xml", + "lib/portable-win81+wpa81/FluentAssertions.dll", + "lib/portable-win81+wpa81/FluentAssertions.pdb", + "lib/portable-win81+wpa81/FluentAssertions.xml", + "lib/sl5/FluentAssertions.Core.dll", + "lib/sl5/FluentAssertions.Core.pdb", + "lib/sl5/FluentAssertions.Core.xml", + "lib/sl5/FluentAssertions.dll", + "lib/sl5/FluentAssertions.pdb", + "lib/sl5/FluentAssertions.xml", + "lib/sl5/Microsoft.CSharp.dll", + "lib/sl5/Microsoft.CSharp.xml", + "lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", + "lib/sl5/Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml", + "lib/sl5/System.Xml.Linq.dll", + "lib/sl5/System.Xml.Linq.xml", + "lib/sl5/de/Microsoft.CSharp.resources.dll", + "lib/sl5/de/System.Xml.Linq.resources.dll", + "lib/sl5/es/Microsoft.CSharp.resources.dll", + "lib/sl5/es/System.Xml.Linq.resources.dll", + "lib/sl5/fr/Microsoft.CSharp.resources.dll", + "lib/sl5/fr/System.Xml.Linq.resources.dll", + "lib/sl5/it/Microsoft.CSharp.resources.dll", + "lib/sl5/it/System.Xml.Linq.resources.dll", + "lib/sl5/ja/Microsoft.CSharp.resources.dll", + "lib/sl5/ja/System.Xml.Linq.resources.dll", + "lib/sl5/ko/Microsoft.CSharp.resources.dll", + "lib/sl5/ko/System.Xml.Linq.resources.dll", + "lib/sl5/ru/Microsoft.CSharp.resources.dll", + "lib/sl5/ru/System.Xml.Linq.resources.dll", + "lib/sl5/zh-Hans/Microsoft.CSharp.resources.dll", + "lib/sl5/zh-Hans/System.Xml.Linq.resources.dll", + "lib/sl5/zh-Hant/Microsoft.CSharp.resources.dll", + "lib/sl5/zh-Hant/System.Xml.Linq.resources.dll", + "lib/win8/FluentAssertions.Core.dll", + "lib/win8/FluentAssertions.Core.pdb", + "lib/win8/FluentAssertions.Core.xml", + "lib/win8/FluentAssertions.dll", + "lib/win8/FluentAssertions.pdb", + "lib/win8/FluentAssertions.XML", + "lib/wp8/FluentAssertions.Core.dll", + "lib/wp8/FluentAssertions.Core.pdb", + "lib/wp8/FluentAssertions.Core.xml", + "lib/wp8/FluentAssertions.dll", + "lib/wp8/FluentAssertions.pdb", + "lib/wp8/FluentAssertions.xml", + "package/services/metadata/core-properties/c21a09dd42de4a6295af89109b879195.psmdcp", + "[Content_Types].xml" + ] + } + }, + "projectFileDependencyGroups": { + "": [], + ".NETFramework,Version=v4.5": [ + "newtonsoft.json >= 8.0.1" + ], + ".NETFramework,Version=v4.6": [ + "fluentassertions >= 3.4.1" + ] + }, + "tools": {}, + "projectFileToolGroups": {}, + "packageFolders": { + "C:\\PackageFolder\\": {} + } +}
\ No newline at end of file diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj b/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj index ccf4463..342af76 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj @@ -34,8 +34,6 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> - <Reference Include="Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="Microsoft.CSharp" /> @@ -78,6 +76,7 @@ <None Include="Json\analyzers.json" /> <None Include="Json\FluentAssertions.lock.json" /> <None Include="Json\FluentAssertionsAndWin10.lock.json" /> + <None Include="Json\MultipleProjectFileDependencyGroups_CaseMismatch.json" /> <None Include="Json\MultipleProjectFileDependencyGroups.json" /> <None Include="Json\nativeWinMD.json" /> <None Include="Json\LockFileWithWithSpecifiedPackageFolders.json" /> diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs b/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs index 145e469..90b6142 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/PackageFolderTests.cs @@ -18,7 +18,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests runtimeIdentifier: null, createTemporaryFolderForPackages: false); - Assert.Equal(@"C:\PackageFolder\newtonsoft.json\8.0.3\lib\net45\Newtonsoft.Json.dll", result.References.Single().ItemSpec); + Assert.Equal(@"C:\PackageFolder\newtonsoft.json\9.0.1\lib\net45\Newtonsoft.Json.dll", result.References.Single().ItemSpec); } } } diff --git a/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs b/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs index 994fdb4..3b690ab 100644 --- a/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs +++ b/src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs @@ -414,6 +414,33 @@ namespace Microsoft.NuGet.Build.Tasks.Tests Assert.Contains("FluentAssertions", packageNames); } + // Regression test for https://devdiv.visualstudio.com/DevDiv/_workitems?id=500532&_a=edit + [Fact] + public static void MultipleProjectFileDependencyGroups_MismatchedCases() + { + var resultFor45 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents( + Json.Json.MultipleProjectFileDependencyGroups_CaseMismatch, + targetMoniker: ".NETFramework,Version=v4.5", + runtimeIdentifier: "win", + allowFallbackOnTargetSelection: true); + + var packageNames = resultFor45.ReferencedPackages.Select(t => t.ItemSpec); + + Assert.Equal("Newtonsoft.Json", packageNames.Single(), ignoreCase: true); + + var resultFor46 = NuGetTestHelpers.ResolvePackagesWithJsonFileContents( + Json.Json.MultipleProjectFileDependencyGroups, + targetMoniker: ".NETFramework,Version=v4.6", + runtimeIdentifier: "win", + allowFallbackOnTargetSelection: true); + + AssertHelpers.AssertCountOf(1, resultFor46.ReferencedPackages); + + packageNames = resultFor46.ReferencedPackages.Select(t => t.ItemSpec); + + Assert.Equal("FluentAssertions", packageNames.Single(), ignoreCase: true); + } + [Fact] public static void ProjectsNotIncludedInReferences() { diff --git a/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj b/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj index 3d8611b..2628d82 100644 --- a/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj +++ b/src/Microsoft.NuGet.Build.Tasks/Microsoft.NuGet.Build.Tasks.csproj @@ -34,8 +34,6 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> - <Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> - <Reference Include="Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="Microsoft.CSharp" /> diff --git a/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs b/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs index f4a7f17..7de0f02 100644 --- a/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs +++ b/src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs @@ -879,7 +879,7 @@ namespace Microsoft.NuGet.Build.Tasks /// </summary> private static SortedSet<string> GetAllPackageNames(JObject lockFile) { - var allPackageNames = new SortedSet<string>(); + var allPackageNames = new SortedSet<string>(StringComparer.OrdinalIgnoreCase); var libraries = (JObject)lockFile["libraries"]; foreach (var library in libraries) { diff --git a/src/Microsoft.NuGet.Build.Tasks/project.json b/src/Microsoft.NuGet.Build.Tasks/project.json index c992ffa..133fa6a 100644 --- a/src/Microsoft.NuGet.Build.Tasks/project.json +++ b/src/Microsoft.NuGet.Build.Tasks/project.json @@ -1,5 +1,12 @@ { - "dependencies": { "Newtonsoft.Json": "6.0.4" }, - "frameworks": { "net45": { } }, - "runtimes": { "win": { } } + "dependencies": { + "Microsoft.Build.Utilities.Core": "14.3.0", + "Newtonsoft.Json": "6.0.4" + }, + "frameworks": { + "net45": {} + }, + "runtimes": { + "win": {} + } }
\ No newline at end of file |