How does the C# compiler decide to emit retargetable assembly references?

前端 未结 3 1242
悲哀的现实
悲哀的现实 2021-02-19 18:04

Retargetable assembly references have been introduced for the .NET Compact Framework and are now used to support Portable Class Libraries.

Basically, the compiler emits

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-19 18:58

    Not sure if this will help, but the following file was auto-generated and included in the build.

    using System;
    using System.Reflection;
    [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(
       ".NETPortable,Version=v4.0,Profile=Profile4", 
       FrameworkDisplayName = ".NET Portable Subset")]
    

    This might hint to the compiler to do some magic.

    Edit:

    I think above makes a library portable. From the command line I can see /nostdlib+ is used, and a portable mscorlib.dll is referenced (which I assume has the same attribute as mentioned above).

    "...\Program Files\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile4\mscorlib.dll"

提交回复
热议问题