diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs index 7f9f70fa6..0f9d291f9 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs @@ -117,7 +117,9 @@ namespace Microsoft.Extensions.DependencyModel { return new JObject( libraries.Select(library => - new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version, WriteTargetLibrary(library)))); + // TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once + // https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI + new JProperty(library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant(), WriteTargetLibrary(library)))); } private JObject WritePortableTarget(IReadOnlyList runtimeLibraries, IReadOnlyList compilationLibraries) @@ -145,7 +147,9 @@ namespace Microsoft.Extensions.DependencyModel var library = (Library)compilationLibrary ?? (Library)runtimeLibrary; targetObject.Add( - new JProperty(library.Name + DependencyContextStrings.VersionSeperator + library.Version, + // TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once + // https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI + new JProperty(library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant(), WritePortableTargetLibrary(runtimeLibrary, compilationLibrary) ) ); @@ -313,7 +317,9 @@ namespace Microsoft.Extensions.DependencyModel { var allLibraries = context.RuntimeLibraries.Cast().Concat(context.CompileLibraries) - .GroupBy(library => library.Name + DependencyContextStrings.VersionSeperator + library.Version); + // TODO: remove the hack of calling "ToLowerInvariant()" on library Name and Version once + // https://github.com/dotnet/core-setup/pull/64/ is merged and taken into the CLI + .GroupBy(library => library.Name.ToLowerInvariant() + DependencyContextStrings.VersionSeperator + library.Version.ToLowerInvariant()); return new JObject(allLibraries.Select(libraries => new JProperty(libraries.Key, WriteLibrary(libraries.First())))); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index 5a04d82dd..9a054533b 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -60,6 +60,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities return new AndConstraint(this); } + public AndConstraint HaveStdOutContainingIgnoreCase(string pattern) + { + Execute.Assertion.ForCondition(_commandResult.StdOut.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0) + .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}")); + return new AndConstraint(this); + } + public AndConstraint HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success) diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs index ca4427ca4..3b43e5f2a 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/DependencyContextJsonWriterTests.cs @@ -131,7 +131,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject; dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0"); library.Should().HavePropertyAsObject("compile") @@ -139,7 +139,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests //libraries var libraries = result.Should().HavePropertyAsObject("libraries").Subject; - library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject; library.Should().HavePropertyValue("sha512", "HASH"); library.Should().HavePropertyValue("type", "package"); library.Should().HavePropertyValue("serviceable", true); @@ -178,7 +178,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject; dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0"); @@ -203,7 +203,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests //libraries var libraries = result.Should().HavePropertyAsObject("libraries").Subject; - library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject; library.Should().HavePropertyValue("sha512", "HASH"); library.Should().HavePropertyValue("type", "package"); library.Should().HavePropertyValue("serviceable", true); @@ -256,7 +256,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject; dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0"); @@ -280,7 +280,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests //libraries var libraries = result.Should().HavePropertyAsObject("libraries").Subject; - library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject; library.Should().HavePropertyValue("sha512", "HASH"); library.Should().HavePropertyValue("type", "package"); library.Should().HavePropertyValue("serviceable", true); @@ -317,7 +317,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target/runtime").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject; dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0"); library.Should().HavePropertyAsObject("runtime") @@ -327,7 +327,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests //libraries var libraries = result.Should().HavePropertyAsObject("libraries").Subject; - library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + library = libraries.Should().HavePropertyAsObject("packagename/1.2.3").Subject; library.Should().HavePropertyValue("sha512", "HASH"); library.Should().HavePropertyValue("type", "package"); library.Should().HavePropertyValue("serviceable", true); @@ -364,7 +364,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var runtimeTargets = library.Should().HavePropertyAsObject("runtimeTargets").Subject; @@ -412,7 +412,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target/runtime").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var resources = library.Should().HavePropertyAsObject("resources").Subject; var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject; resource.Should().HavePropertyValue("locale", "en-US"); @@ -446,7 +446,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; var resources = library.Should().HavePropertyAsObject("resources").Subject; var resource = resources.Should().HavePropertyAsObject("en-US/Fruits.resources.dll").Subject; resource.Should().HavePropertyValue("locale", "en-US"); @@ -478,7 +478,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests // targets var targets = result.Should().HavePropertyAsObject("targets").Subject; var target = targets.Should().HavePropertyAsObject("Target").Subject; - var library = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject; + var library = target.Should().HavePropertyAsObject("packagename/1.2.3").Subject; library.Should().HavePropertyValue("compileOnly", true); } diff --git a/test/Microsoft.Extensions.DependencyModel.Tests/FunctionalTests.cs b/test/Microsoft.Extensions.DependencyModel.Tests/FunctionalTests.cs index 476671ebb..c0e4de7e5 100644 --- a/test/Microsoft.Extensions.DependencyModel.Tests/FunctionalTests.cs +++ b/test/Microsoft.Extensions.DependencyModel.Tests/FunctionalTests.cs @@ -93,17 +93,17 @@ namespace Microsoft.Extensions.DependencyModel private void ValidateRuntimeLibrariesFullClr(CommandResult result, string appname) { // entry assembly - result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}"); + result.Should().HaveStdOutContaining($"Runtime {appname.ToLowerInvariant()}:{appname}"); // project dependency - result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator"); + result.Should().HaveStdOutContaining("Runtime dependencycontextvalidator:DependencyContextValidator"); } private void ValidateCompilationLibrariesFullClr(CommandResult result, string appname) { // entry assembly - result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.exe"); + result.Should().HaveStdOutContaining($"Compilation {appname.ToLowerInvariant()}:{appname}.exe"); // project dependency - result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll"); + result.Should().HaveStdOutContaining("Compilation dependencycontextvalidator:DependencyContextValidator.dll"); // system assembly result.Should().HaveStdOutContaining("Compilation mscorlib:mscorlib.dll"); } @@ -112,22 +112,21 @@ namespace Microsoft.Extensions.DependencyModel private void ValidateRuntimeLibraries(CommandResult result, string appname) { // entry assembly - result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}"); + result.Should().HaveStdOutContaining($"Runtime {appname.ToLowerInvariant()}:{appname}"); // project dependency - result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator"); + result.Should().HaveStdOutContaining("Runtime dependencycontextvalidator:DependencyContextValidator"); // system assembly - result.Should().HaveStdOutContaining("Runtime System.Linq:System.Linq"); + result.Should().HaveStdOutContainingIgnoreCase("Runtime System.Linq:System.Linq"); } private void ValidateCompilationLibraries(CommandResult result, string appname) { // entry assembly - result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.dll"); + result.Should().HaveStdOutContaining($"Compilation {appname.ToLowerInvariant()}:{appname}.dll"); // project dependency - result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll"); + result.Should().HaveStdOutContaining("Compilation dependencycontextvalidator:DependencyContextValidator.dll"); // system assembly - result.Should().HaveStdOutContaining("Compilation System.Linq:System.Linq.dll"); + result.Should().HaveStdOutContainingIgnoreCase("Compilation System.Linq:System.Linq.dll"); } - } } diff --git a/test/dotnet-build.Tests/BuildOutputTests.cs b/test/dotnet-build.Tests/BuildOutputTests.cs index e0d508001..71139968e 100644 --- a/test/dotnet-build.Tests/BuildOutputTests.cs +++ b/test/dotnet-build.Tests/BuildOutputTests.cs @@ -278,7 +278,11 @@ namespace Microsoft.DotNet.Tools.Builder.Tests foreach (var library in new[] { Tuple.Create("Microsoft.Data.OData", "5.6.4"), Tuple.Create("TestLibraryWithResources", "1.0.0") }) { - var resources = depsJson["targets"][".NETCoreApp,Version=v1.0"][library.Item1 + "/" + library.Item2]["resources"]; + var resources = depsJson + ["targets"] + [".NETCoreApp,Version=v1.0"] + [library.Item1.ToLowerInvariant() + "/" + library.Item2.ToLowerInvariant()] + ["resources"]; resources.Should().NotBeNull();