Skip to content

Commit 475e264

Browse files
authored
Merge pull request #876 from eerhardt/Fix120
Allow .NET Core 2.0 projects to reference assemblies on disk
2 parents af0910f + 27fc65c commit 475e264

16 files changed

+2898
-50
lines changed

build/DependencyVersions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<!-- Dependencies from test projects -->
1313
<PropertyGroup>
14+
<MicrosoftNETCoreApp20Version>2.0.0-beta-001509-00</MicrosoftNETCoreApp20Version>
1415
<xunitVersion>2.1.0</xunitVersion>
1516
<FluentAssertionsVersion>4.0.0</FluentAssertionsVersion>
1617
<FluentAssertionsJsonVersion>4.12.0</FluentAssertionsJsonVersion>

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

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public void ItBuildsDependencyContextsFromProjectLockFiles(
2828
CompilationOptions compilationOptions,
2929
string baselineFileName,
3030
string runtime,
31-
ITaskItem[] satelliteAssemblies)
31+
ITaskItem[] assemblySatelliteAssemblies,
32+
ITaskItem[] referencePaths,
33+
ITaskItem[] referenceSatellitePaths)
3234
{
3335
LockFile lockFile = TestLockFiles.GetLockFile(mainProjectName);
3436

@@ -37,14 +39,20 @@ public void ItBuildsDependencyContextsFromProjectLockFiles(
3739
mainProjectName,
3840
".dll",
3941
mainProjectVersion,
40-
satelliteAssemblies ?? new ITaskItem[] { });
42+
assemblySatelliteAssemblies ?? new ITaskItem[] { });
43+
44+
IEnumerable<ReferenceInfo> directReferences =
45+
ReferenceInfo.CreateDirectReferenceInfos(
46+
referencePaths ?? new ITaskItem[] { },
47+
referenceSatellitePaths ?? new ITaskItem[] { });
4148

4249
ProjectContext projectContext = lockFile.CreateProjectContext(
4350
FrameworkConstants.CommonFrameworks.NetCoreApp10,
4451
runtime,
4552
Constants.DefaultPlatformLibrary);
4653

4754
DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, projectContext)
55+
.WithDirectReferences(directReferences)
4856
.WithCompilationOptions(compilationOptions)
4957
.Build();
5058

@@ -108,14 +116,42 @@ public static IEnumerable<object[]> ProjectData
108116
}),
109117
};
110118

119+
ITaskItem[] referencePaths = new ITaskItem[]
120+
{
121+
new MockTaskItem(
122+
"/usr/Path/RandomLooseLibrary.dll",
123+
new Dictionary<string, string>
124+
{
125+
{ "CopyLocal", "true" },
126+
{ "FusionName", "RandomLooseLibrary, Version=1.2.0.4, Culture=neutral, PublicKeyToken=null" },
127+
{ "ReferenceSourceTarget", "ResolveAssemblyReference" },
128+
{ "Version", "" },
129+
}),
130+
};
131+
132+
ITaskItem[] referenceSatellitePaths = new ITaskItem[]
133+
{
134+
new MockTaskItem(
135+
@"/usr/Path/fr/RandomLooseLibrary.resources.dll",
136+
new Dictionary<string, string>
137+
{
138+
{ "CopyLocal", "true" },
139+
{ "DestinationSubDirectory", "fr/" },
140+
{ "OriginalItemSpec", "/usr/Path/RandomLooseLibrary.dll" },
141+
{ "ResolvedFrom", "{RawFileName}" },
142+
{ "Version", "" },
143+
}),
144+
};
145+
111146
return new[]
112147
{
113-
new object[] { "dotnet.new", "1.0.0", null, "dotnet.new", null, null},
114-
new object[] { "dotnet.new", "1.0.0", null, "dotnet.new.resources", null, dotnetNewSatelliteAssemblies },
115-
new object[] { "simple.dependencies", "1.0.0", null, "simple.dependencies", null, null },
116-
new object[] { "simple.dependencies", "1.0.0", compilationOptions, "simple.dependencies.compilerOptions", null, null},
117-
new object[] { "all.asset.types", "1.0.0", null, "all.asset.types.portable", null, null },
118-
new object[] { "all.asset.types", "1.0.0", null, "all.asset.types.osx", "osx.10.11-x64", null },
148+
new object[] { "dotnet.new", "1.0.0", null, "dotnet.new", null, null, null, null},
149+
new object[] { "dotnet.new", "1.0.0", null, "dotnet.new.resources", null, dotnetNewSatelliteAssemblies, null, null },
150+
new object[] { "simple.dependencies", "1.0.0", null, "simple.dependencies", null, null, null, null },
151+
new object[] { "simple.dependencies", "1.0.0", compilationOptions, "simple.dependencies.compilerOptions", null, null, null, null},
152+
new object[] { "simple.dependencies", "1.0.0", compilationOptions, "simple.dependencies.directReference", null, null, referencePaths, referenceSatellitePaths},
153+
new object[] { "all.asset.types", "1.0.0", null, "all.asset.types.portable", null, null, null, null },
154+
new object[] { "all.asset.types", "1.0.0", null, "all.asset.types.osx", "osx.10.11-x64", null, null, null },
119155
};
120156
}
121157
}

src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/Microsoft.NET.Build.Tasks.UnitTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
<None Include="LockFiles\dotnet.new.project.lock.json">
8282
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8383
</None>
84+
<None Include="simple.dependencies.directReference.deps.json">
85+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
86+
</None>
8487
<None Include="simple.dependencies.compilerOptions.deps.json">
8588
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8689
</None>

0 commit comments

Comments
 (0)