question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reference metadata is not preserved by ImplicitlyExpandNETStandardFacades

See original GitHub issue

For a project targeting .Net Framework 4.7.1 with a reference to netstandard libraries, the target ImplicitlyExpandNETStandardFacades replaces certain references with their Facades so netstandard based assemblies work as expected. This currently works great if the project does not associate metadata(like aliases) with any of these references, but when it does - those aren’t honored breaking build.

Filing this issue to ensure that the missing metadata is preserved when the replacement is done.

Adding few more details, here is the reference in question:

<ReferenceInclude="System.Net.Http">
     <HintPath>E:\SomeRandomProjectPath\bin\debug\System.Net.Http.dll</HintPath>
     <Aliases>snh</Aliases>
     <EmbedInteropTypes>False</EmbedInteropTypes>
   </Reference>

and here is what is passed on to csc:

E:\Program Files (x86)\Microsoft Visual Studio\15.7Prev\Enterprise\MSBuild\15.0\bin\Roslyn\csc.exe /noconfig /unsafe+ /nowarn:1587,1591,1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+  /reference:"E:\Program Files (x86)\Microsoft Visual Studio\15.7Prev\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.dll ...."

Notice the missing alias to System.Net.http.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dsplaistedcommented, May 24, 2018

For reference, the workaround posted for the Fakes issue is to put the following in Directory.Build.targets:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  
  <Target Name="PrivateFakesAfterFacadesSwitch"
            Condition="'$(ImplicitlyExpandNETStandardFacades)' == 'true' and $(AssemblyName.EndsWith('.Fakes'))"
            AfterTargets="ImplicitlyExpandNETStandardFacades" DependsOnTargets="ImplicitlyExpandNETStandardFacades">

    <ItemGroup Condition="'@(_NETStandardLibraryNETFrameworkLib)' != ''">
      <SnhReference Include = "@(_NETStandardLibraryNETFrameworkLib)" Condition="'%(_NETStandardLibraryNETFrameworkLib.FileName)' == 'System.Net.Http'" />
      
      <Reference Remove="%(SnhReference.FileName)" Condition="'@(SnhReference)' != ''"/>
      <Reference Include="%(SnhReference.FileName)" Condition="'@(SnhReference)' != ''">
        <HintPath>%(SnhReference.Identity)</HintPath>
        <Private>false</Private>
        <Aliases>snh</Aliases>
      </Reference>
    </ItemGroup>

  </Target>

</Project>
0reactions
dsplaistedcommented, Feb 18, 2020

@entei-11 Yes, this fix is only available in the .NET Core SDK 3.0.100 and higher, which only works with VS 2019.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.NET.Build.Extensions.NETFramework.targets
However, we want to preserve custom metadata on those simple name references (for example for aliases). That's what this task does.
Read more >
NETSDK1130: Can't reference a Windows Metadata ...
How to resolve the issue of not being able to reference a Windows Metadata component directly from an app that targets .NET 5...
Read more >
"ReferencePath" does not define a value for metadata ...
Right click on 'References' in the project solution -> select 'Migrate ... "ReferencePath" does not define a value for metadata "CopyLocal".
Read more >
UWP IL2CPP GameAssembly missing
I have ported a .net to il2cpp backend and I can't get any of my projects to work. 1>LINK : fatal error LNK1104:...
Read more >
out.txt
Honor SkipGetTargetFrameworkProperties=true metadata on project references to mean that the project reference is known not to target multiple frameworks and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found