Search code examples
c#.netilmerge

Target .Net 4.0 when using Windows 8 / VS2012


I am having some issues building a merged DLL to target .net4.0 on a windows 8 machine. I can successfully build individual .net4.0 dlls in VS2012 so I do not have this problem:

Targeting .NET 4.0 in VS 2012 on Windows 8

I have come across the following excellent blog post which discuss my issue:

http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx

and also:

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib

which suggests I use the following syntax during the merge:

/targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

Unfortunately in windows 8 I do not have this directory. I can think of the following possible solutions but would be interested to know if anyone has already solved this.

  1. Copy the .net 4.0 assemblies from a windows 7 machine into the above directory manually.
  2. Find the .net 4.0 assemblies being used by VS2012 and reference those.
  3. ??

Solution

  • Many thanks for the comments and feedback. A working (hacky) solution was to do the following:

    1. Create a new directory on windows 8, C:\Program Files\Reference Assemblies\Microsoft\Framework\v4.0.
    2. Go to a windows 7 machine, which does not have .net4.5 installed, and copy the contents of the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319
    3. Paste the files from step 2 into the folder created in step 1.

    I was then able to correctly reference the .net4.0 assemblies in Windows 8 using the following:

    /targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\v4.0"
    

    Tested as working ok.