Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .NET Standard facades without reference assembly bit set #1612

Merged
merged 6 commits into from
Oct 10, 2017
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,28 @@ Copyright (c) .NET Foundation. All rights reserved.
targets. -->
<Reference Remove="%(_NETStandardLibraryNETFrameworkLib.FileName)" />

<Reference Include="@(_NETStandardLibraryNETFrameworkLib)">
<!-- netfx.force.conflicts is only needed at compile time. -->
<Private Condition="'%(FileName)' == 'netfx.force.conflicts'">false</Private>
<!-- Put each facade assembly in two separate items: Reference with Private set to false, which means it won't be
copied locally, and ReferenceCopyLocalPaths, which will be copied locally. The reason for this split is to
workaround https://github.com/dotnet/core-setup/issues/2981 by ensuring that the facades are written
to the deps.json with a type of "referenceassembly" instead of "reference".

The exception is netfx.force.conflicts.dll, which shouldn't be copied local. So it isn't included in
ReferenceCopyLocalPaths.

When we add the Reference items, we use the simple name as the ItemSpec, and refer to the full path
to the DLL via the HintPath metadata. This is so that if we're replacing a simple Reference,
the OriginalItemSpec of the resolved reference will match to the Reference that was replaced,
and VS won't show a warning icon on the reference. See https://github.com/dotnet/sdk/issues/1499
-->

<Reference Include="@(_NETStandardLibraryNETFrameworkLib.FileName)">
<HintPath>%(_NETStandardLibraryNETFrameworkLib.Identity)</HintPath>
<Private>false</Private>
</Reference>

<ReferenceCopyLocalPaths Include="@(_NETStandardLibraryNETFrameworkLib)" Condition="'%(FileName)' != 'netfx.force.conflicts'">
<Private>false</Private>
</ReferenceCopyLocalPaths>
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ public void It_supports_copylocal_false_references()
};

testProject.AdditionalProperties.Add("PreserveCompilationContext", "true");
testProject.PackageReferences.Add(new TestPackageReference("NETStandard.Library.NETFramework", "2.0.0-preview2-25330-01", null));

var testReference = new TestProject()
{
Name = "NetStandardLibrary",
TargetFrameworks = "netstandard2.0",
IsSdkProject = true,
IsExe = false
};

testProject.ReferencedProjects.Add(testReference);

var testAsset = _testAssetsManager.CreateTestProject(testProject)
.Restore(Log, testProject.Name);
Expand All @@ -59,7 +68,8 @@ public void It_supports_copylocal_false_references()
.Select(a => a.Split('/').Last())
.ToList();

compileLibraryAssemblyNames.Should().BeEquivalentTo(Net461CompileAssemblies);
compileLibraryAssemblyNames.Should().BeEquivalentTo(
Net461CompileAssemblies.Concat(new[] { testReference.Name + ".dll" }));
}
}

Expand Down