Skip to content

Commit 6a09c4c

Browse files
committed
Little tweaks (one per dsplaisted's suggestion)
1 parent e73d3df commit 6a09c4c

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenADependencyContextBuilder.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void ItHandlesReferenceAndPackageReferenceNameCollisions()
218218
}
219219

220220
// If an assembly is in withResources, it has to be a key in dependencies, even with an empty list.
221-
private DependencyContext BuildDependencyContextFromDependenciesWithResources(Dictionary<string, List<string>> dependencies, List<string> withResources, List<string> directReferences)
221+
private static DependencyContext BuildDependencyContextFromDependenciesWithResources(Dictionary<string, List<string>> dependencies, List<string> withResources, List<string> references)
222222
{
223223
string mainProjectName = "simpleApp";
224224
LockFile lockFile = TestLockFiles.GetLockFile(mainProjectName);
@@ -231,7 +231,7 @@ private DependencyContext BuildDependencyContextFromDependenciesWithResources(Di
231231
[]);
232232
string mainProjectDirectory = Path.GetDirectoryName(mainProject.ProjectPath);
233233

234-
ITaskItem[] referencePaths = directReferences.Select(reference =>
234+
ITaskItem[] referencePaths = references.Select(reference =>
235235
new MockTaskItem($"/usr/Path/{reference}.dll", new Dictionary<string, string> {
236236
{ "CopyLocal", "false" },
237237
{ "FusionName", $"{reference}, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" },
@@ -279,18 +279,9 @@ private DependencyContext BuildDependencyContextFromDependenciesWithResources(Di
279279

280280
CompilationOptions compilationOptions = CreateCompilationOptions();
281281

282-
/* IEnumerable<ReferenceInfo> references =
283-
ReferenceInfo.CreateDirectReferenceInfos(
284-
referencePaths,
285-
[],
286-
lockFileLookup: new LockFileLookup(lockFile),
287-
i => true,
288-
true);
289-
*/
290282
return new DependencyContextBuilder(mainProject, includeRuntimeFileVersions: false, runtimeGraph: null, projectContext: projectContext, libraryLookup: new LockFileLookup(lockFile))
291283
.WithReferenceAssemblies(ReferenceInfo.CreateReferenceInfos(referencePaths))
292284
.WithCompilationOptions(compilationOptions)
293-
// .WithDirectReferences(references)
294285
.WithReferenceProjectInfos(referenceProjectInfos)
295286
.Build();
296287
}

src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,20 @@ public DependencyContext Build(string[] userRuntimeAssemblies = null)
481481
targetInfo,
482482
_compilationOptions ?? CompilationOptions.Default,
483483
compilationLibraries,
484-
runtimeLibraries.Select(library => library.Library),
484+
runtimeLibraries.Select(library => new RuntimeLibrary(
485+
library.Library.Type,
486+
library.Library.Name,
487+
library.Library.Version,
488+
library.Library.Hash,
489+
library.Library.RuntimeAssemblyGroups,
490+
library.Library.NativeLibraryGroups,
491+
library.Library.ResourceAssemblies,
492+
library.Library.Dependencies.Where(
493+
dependency => runtimeLibraries.Any(lib => lib.Library.Name.Equals(dependency.Name)) ||
494+
compilationLibraries.Any(lib => lib.Name.Equals(dependency.Name))).ToList(),
495+
library.Library.Serviceable,
496+
library.Library.Path,
497+
library.Library.HashPath)),
485498
runtimeFallbackGraph);
486499
}
487500

0 commit comments

Comments
 (0)