How to identify that an assembly has been compiled with/for .NET 4.5, as opposed to .NET 4.0?

后端 未结 2 1113
你的背包
你的背包 2021-01-12 17:23

I have some build agents that is building .NET code for us through a TeamCity setup, and I\'m beginning to wonder if despite the project settings, they\'re outputting .NET 4

2条回答
  •  無奈伤痛
    2021-01-12 17:44

    Run ildasm.exe and look at the manifest. You'll see the TargetFrameworkAttribute:

    .custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = 
    ( 01 00 1A 2E 4E 45 54 46 72 61 6D 65 77 6F 72 6B   // ....NETFramework
      2C 56 65 72 73 69 6F 6E 3D 76 34 2E 35 01 00 54   // ,Version=v4.5..T
      0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C   // ..FrameworkDispl
      61 79 4E 61 6D 65 12 2E 4E 45 54 20 46 72 61 6D   // ayName..NET Fram
      65 77 6F 72 6B 20 34 2E 35 )                      // ework 4.5
    

    The CLR uses this attribute to verify that the correct version is present on the machine, prompting the user to get it automatically installed if it is not.

提交回复
热议问题