Workaround native deps resolver not lower casing the file paths into the NuGet cache.

This is needed until https://github.com/dotnet/core-setup/pull/64 is merged.
This commit is contained in:
Eric Erhardt 2016-07-26 15:41:45 -05:00
parent 74da44a2bf
commit efc0efe4f9
5 changed files with 43 additions and 27 deletions

View file

@ -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<RuntimeLibrary> runtimeLibraries, IReadOnlyList<CompilationLibrary> 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<Library>().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()))));
}

View file

@ -60,6 +60,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> 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<CommandResultAssertions>(this);
}
public AndConstraint<CommandResultAssertions> HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None)
{
Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success)

View file

@ -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);
}

View file

@ -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");
}
}
}

View file

@ -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();