After NuGet started lower casing the packages, we started hitting issues where we failed to locate dependencies under our list of libraries due to different casing in the libraries names. The fix here is to compare the library names ignoring casing.

This commit is contained in:
Livar Cunha 2016-07-28 21:17:32 -07:00
parent ad66b8935c
commit b05b0e6dc5
13 changed files with 32 additions and 19 deletions

View file

@ -77,6 +77,6 @@ if (!(Test-Path "$DOTNET_LOCAL_PATH"))
}
# Initialize build tools
cmd /c "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd $RepoRoot $env:DOTNET_INSTALL_DIR\dotnet.exe $BUILD_TOOLS_PATH" >> "$INIT_TOOLS_LOG"
cmd /c "$BUILD_TOOLS_PACKAGE_PATH\init-tools.cmd $RepoRoot $env:DOTNET_LOCAL_PATH\dotnet.exe $BUILD_TOOLS_PATH" >> "$INIT_TOOLS_LOG"
Write-Host "Done initializing tools."
Write-Host "Init-Tools completed for BuildTools Version: $BUILD_TOOLS_VERSION" > $BUILD_TOOLS_SEMAPHORE

View file

@ -24,7 +24,7 @@ __BUILD_TOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.j
__BUILD_TOOLS_PACKAGE_VERSION=$(cat $DIR/BuildToolsVersion.txt)
__BUILD_TOOLS_PATH=$NUGET_PACKAGES/Microsoft.DotNet.BuildTools/$__BUILD_TOOLS_PACKAGE_VERSION/lib
__BUILD_TOOLS_SEMAPHORE=$__BUILD_TOOLS_DIR/init-tools.completed
__DOTNET_CMD=$DOTNET_INSTALL_DIR/dotnet
__DOTNET_CMD=$__BUILD_TOOLS_CLI_DIR/dotnet
__PROJECT_JSON_PATH=$__BUILD_TOOLS_DIR/$__BUILD_TOOLS_PACKAGE_VERSION
__PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json
__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }"

View file

@ -158,7 +158,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
private void WriteDepsFileAndCopyProjectDependencies(LibraryExporter exporter, bool skipRuntimeConfig)
{
var exports = exporter.GetAllExports().ToList();
var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name);
var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name, StringComparer.OrdinalIgnoreCase);
var platformExclusionList = _context.GetPlatformExclusionList(exportsLookup);
var filteredExports = exports.FilterExports(platformExclusionList);

View file

@ -46,7 +46,7 @@ namespace Microsoft.Extensions.DependencyModel
.Select(export => export.Library.Identity)
.Distinct()
.Select(identity => new Dependency(identity.Name, identity.Version.ToString()))
.ToDictionary(dependency => dependency.Name);
.ToDictionary(dependency => dependency.Name, StringComparer.OrdinalIgnoreCase);
var compilationOptions = compilerOptions != null
? GetCompilationOptions(compilerOptions)

View file

@ -21,7 +21,10 @@ namespace Microsoft.DotNet.ProjectModel.Graph
_reader = reader;
var msbuildProjectLibraries = lockFile.ProjectLibraries.Where(MSBuildDependencyProvider.IsMSBuildProjectLibrary);
_msbuildTargetLibraries = msbuildProjectLibraries.ToDictionary(GetProjectLibraryKey, l => GetTargetsForLibrary(_lockFile, l));
_msbuildTargetLibraries = msbuildProjectLibraries.ToDictionary(
GetProjectLibraryKey,
l => GetTargetsForLibrary(_lockFile, l),
StringComparer.OrdinalIgnoreCase);
}
public void Patch()
@ -53,7 +56,7 @@ namespace Microsoft.DotNet.ProjectModel.Graph
throw new LockFilePatchingException($"Export file {exportFile.ExportFilePath} has a different version than the lock file {_lockFile.LockFilePath}");
}
var exportDict = exportFile.Exports.ToDictionary(GetTargetLibraryKey);
var exportDict = exportFile.Exports.ToDictionary(GetTargetLibraryKey, StringComparer.OrdinalIgnoreCase);
var uncoveredLibraries = _msbuildTargetLibraries.Keys.Except(exportDict.Keys);
if (uncoveredLibraries.Any())

View file

@ -588,7 +588,10 @@ namespace Microsoft.DotNet.ProjectModel
type = LibraryType.Package;
}
description = description ?? UnresolvedDependencyProvider.GetDescription(new LibraryRange(library.Name, type), target.TargetFramework);
description = description ??
UnresolvedDependencyProvider.GetDescription(
new LibraryRange(library.Name, type),
target.TargetFramework);
libraries.Add(new LibraryKey(library.Name), description);
}
@ -674,14 +677,14 @@ namespace Microsoft.DotNet.ProjectModel
{
var otherKey = (LibraryKey)obj;
return string.Equals(otherKey.Name, Name, StringComparison.Ordinal) &&
return string.Equals(otherKey.Name, Name, StringComparison.OrdinalIgnoreCase) &&
otherKey.LibraryType.Equals(LibraryType);
}
public override int GetHashCode()
{
var combiner = new HashCodeCombiner();
combiner.Add(Name);
combiner.Add(Name.ToLowerInvariant());
combiner.Add(LibraryType);
return combiner.CombinedHash;

View file

@ -67,7 +67,9 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
if (targetLibrary != null)
{
// The lock file entry might have a filtered set of dependencies
var lockFileDependencies = targetLibrary.Dependencies.ToDictionary(d => d.Id);
var lockFileDependencies = targetLibrary.Dependencies.ToDictionary(
d => d.Id,
StringComparer.OrdinalIgnoreCase);
// Remove all non-framework dependencies that don't appear in the lock file entry
dependencies.RemoveAll(m => !lockFileDependencies.ContainsKey(m.Name) && m.Target != LibraryType.ReferenceAssembly);

View file

@ -124,8 +124,8 @@ namespace Microsoft.Extensions.DependencyModel
private JObject WritePortableTarget(IReadOnlyList<RuntimeLibrary> runtimeLibraries, IReadOnlyList<CompilationLibrary> compilationLibraries)
{
var runtimeLookup = runtimeLibraries.ToDictionary(l => l.Name);
var compileLookup = compilationLibraries.ToDictionary(l => l.Name);
var runtimeLookup = runtimeLibraries.ToDictionary(l => l.Name, StringComparer.OrdinalIgnoreCase);
var compileLookup = compilationLibraries.ToDictionary(l => l.Name, StringComparer.OrdinalIgnoreCase);
var targetObject = new JObject();

View file

@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Build
foreach (var context in contexts)
{
var libraries = context.LibraryManager.GetLibraries();
var lookup = libraries.ToDictionary(l => l.Identity.Name);
var lookup = libraries.ToDictionary(l => l.Identity.Name, StringComparer.OrdinalIgnoreCase);
var root = lookup[context.ProjectFile.Name];
yield return TraverseProject((ProjectDescription) root, lookup, context);
}

View file

@ -96,10 +96,13 @@ namespace Microsoft.DotNet.Tools.Compiler
public static List<CultureResgenIO> GetCultureResources(Project project, string outputPath)
{
return
(from resourceFileGroup in project.Files.ResourceFiles.GroupBy(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
(from resourceFileGroup in project.Files.ResourceFiles.GroupBy(
resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
let culture = resourceFileGroup.Key
where !string.IsNullOrEmpty(culture)
let inputFileToMetadata = resourceFileGroup.ToDictionary(r => r.Key, r => GetResourceFileMetadataName(project, r.Key, r.Value))
let inputFileToMetadata = resourceFileGroup.ToDictionary(
r => r.Key,
r => GetResourceFileMetadataName(project, r.Key, r.Value))
let resourceOutputPath = Path.Combine(outputPath, culture)
let outputFile = Path.Combine(resourceOutputPath, project.Name + ".resources.dll")
select new CultureResgenIO(culture, inputFileToMetadata, outputFile)

View file

@ -126,7 +126,9 @@ namespace Microsoft.DotNet.Tools.Compiler
if (compilationOptions.PreserveCompilationContext == true)
{
var allExports = exporter.GetAllExports().ToList();
var exportsLookup = allExports.ToDictionary(e => e.Library.Identity.Name);
var exportsLookup = allExports.ToDictionary(
e => e.Library.Identity.Name,
StringComparer.OrdinalIgnoreCase);
var buildExclusionList = context.GetTypeBuildExclusionList(exportsLookup);
var filteredExports = allExports
.Where(e => e.Library.Identity.Type.Equals(LibraryType.ReferenceAssembly) ||

View file

@ -134,7 +134,7 @@ namespace Microsoft.DotNet.Tools.Publish
var exports = exporter.GetAllExports();
var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name);
var exportsLookup = exports.ToDictionary(e => e.Library.Identity.Name, StringComparer.OrdinalIgnoreCase);
var platformExclusionList = context.GetPlatformExclusionList(exportsLookup);
var buildExclusionList = context.GetTypeBuildExclusionList(exportsLookup);
var allExclusionList = new HashSet<string>(platformExclusionList);

View file

@ -126,7 +126,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
.Build();
// Will fail with dupes if any
context.LibraryManager.GetLibraries().ToDictionary(l => l.Identity.Name);
context.LibraryManager.GetLibraries().ToDictionary(l => l.Identity.Name, StringComparer.OrdinalIgnoreCase);
}
[Fact]
@ -153,7 +153,7 @@ namespace Microsoft.DotNet.ProjectModel.Tests
.Build();
// Will fail with dupes if any
context.LibraryManager.GetLibraries().ToDictionary(l => l.Identity.Name);
context.LibraryManager.GetLibraries().ToDictionary(l => l.Identity.Name, StringComparer.OrdinalIgnoreCase);
}
}
}