Deriving a Reference Assemblies path from a TargetFrameworkAttribute

275 views Asked by At

I'm processing assemblies with Mono.Cecil in a standalone tool. The tool is intended to be framework-neutral (i.e. will load in any .NET 4[.x[.x]] environment] and not have a dependency on e.g. the .NET SDK.

Say I have an assembly containing the following TargetFrameworkAttribute in its IL:

[assembly: TargetFramework(".NETFramework,Version=v4.0", 
   FrameworkDisplayName = ".NET Framework 4")]

What is the correct way to map that to what I believe to be the correct path:-

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

I'm hoping there's a relatively clean way to manage this from within .NET code.

Is there a standard way to obtain C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework programmatically? Can the obvious subfolder pattern within this be relied on -- i.e. is there any documentation other than this ?


I can see MSBuild via Microsoft.Common.targets and Microsoft.NETFramework.props has quite the warren of 'optimized' logic around this. Even if I was to be willing to shell out to that and e.g. using a Task in there would be too brittle and taking a dependency on discovering the MSBuild tools (v12/4 ...) wouldn't be ideal. Any ideas?

0

There are 0 answers