Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/NuGet.BuildTasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Meschter <tom.meschter@microsoft.com>2017-09-29 00:41:55 +0300
committerTom Meschter <tomescht@microsoft.com>2017-09-29 21:19:20 +0300
commit84388f19c4b8206fef2c1393cf2f799994e8e515 (patch)
treeb37e0a876588d0597ca745abe6a655f77da11d26
parent84052003912e2718017e65673c3b72a0dbc083a7 (diff)
Ignore case when matching package names
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/500532. We may need to vary which packages (or versions of packages) to pull in depending on the target framework. In the assets/lock file this is supported by the projectFileDependencyGroups section. This contains an entry for each supported framework, and the entry lists the packages used when targeting that framework. In addition, there is a "universal" entry (denoted by an empty name) for packages that are used in all frameworks. To determine which packages to list in Solution Explorer we match items in the relevant projectFileDependencyGroups item against the packages listed in the "libraries" section. However, we are currently doing this comparison in a case-sensitive manner, even though NuGet packages names are case-insensitive. This means that if the package name differs in case between the two, we won't find it and it won't show up in Solution Explorer. This is "just" a display issue, as the build and Intellisense are unaffected. Still, it is disconcerting for the user, as packages may suddenly "disappear" during package management operations.
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.Designer.cs38
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/Json.resx3
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Json/MultipleProjectFileDependencyGroups_CaseMismatch.json150
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/Microsoft.NuGet.Build.Tasks.Tests.csproj1
-rw-r--r--src/Microsoft.NuGet.Build.Tasks.Tests/ReferenceResolutionTests.cs27
-rw-r--r--src/Microsoft.NuGet.Build.Tasks/ResolveNuGetPackageAssets.cs2
6 files changed, 216 insertions, 5 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 {
/// &quot;version&quot;: 2,
/// &quot;targets&quot;: {
/// &quot;.NETFramework,Version=v4.5&quot;: {
- /// &quot;Newtonsoft.Json/8.0.3&quot;: {
+ /// &quot;Newtonsoft.Json/9.0.1&quot;: {
/// &quot;type&quot;: &quot;package&quot;,
/// &quot;compile&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
@@ -164,7 +164,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
/// }
/// },
/// &quot;libraries&quot;: {
- /// &quot;Newtonsoft.Json/8.0.3&quot;: {
+ /// &quot;Newtonsoft.Json/9.0.1&quot;: {
/// &quot;sha512&quot;: &quot;KGsYQdS2zLH+H8x2cZaSI7e+YZ4SFIbyy1YJQYl6GYBWjf5o4H1A68nxyq+WTyVSOJQ4GqS/DiPE+UseUizgMg==&quot;,
/// &quot;type&quot;: &quot; [rest of string was truncated]&quot;;.
/// </summary>
@@ -180,7 +180,7 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
/// &quot;version&quot;: 2,
/// &quot;targets&quot;: {
/// &quot;.NETFramework,Version=v4.5&quot;: {
- /// &quot;Newtonsoft.Json/8.0.3&quot;: {
+ /// &quot;Newtonsoft.Json/9.0.1&quot;: {
/// &quot;type&quot;: &quot;package&quot;,
/// &quot;compile&quot;: {
/// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
@@ -207,6 +207,36 @@ namespace Microsoft.NuGet.Build.Tasks.Tests.Json {
/// <summary>
/// Looks up a localized string similar to {
/// &quot;locked&quot;: false,
+ /// &quot;version&quot;: 2,
+ /// &quot;targets&quot;: {
+ /// &quot;.NETFramework,Version=v4.5&quot;: {
+ /// &quot;Newtonsoft.Json/9.0.1&quot;: {
+ /// &quot;type&quot;: &quot;package&quot;,
+ /// &quot;compile&quot;: {
+ /// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
+ /// },
+ /// &quot;runtime&quot;: {
+ /// &quot;lib/net45/Newtonsoft.Json.dll&quot;: {}
+ /// }
+ /// }
+ /// },
+ /// &quot;.NETFramework,Version=v4.6&quot;: {
+ /// &quot;FluentAssertions/3.4.1&quot;: {
+ /// &quot;frameworkAssemblies&quot;: [
+ /// &quot;System.Xml&quot;,
+ /// &quot;System.Xml.Linq&quot;
+ /// ],
+ /// [rest of string was truncated]&quot;;.
+ /// </summary>
+ internal static string MultipleProjectFileDependencyGroups_CaseMismatch {
+ get {
+ return ResourceManager.GetString("MultipleProjectFileDependencyGroups_CaseMismatch", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to {
+ /// &quot;locked&quot;: false,
/// &quot;version&quot;: 1,
/// &quot;targets&quot;: {
/// &quot;.NETCore,Version=v5.0&quot;: {
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/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 2359490..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
@@ -76,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/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/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)
{