Today I started the process of upgrading a lot of projects to Visual Studio 2010 and at the same time I set the target framework to 4.0.
Everything went relatively smooth except for the some projects where we have modified the msbuild file to include a call to ILMerge.
First it complained it could not resolve the reference to System.Core
Unresolved assembly reference not allowed: System.Core.
As it turned out I needed to tell ILMerge what framework version to use and where it is located.
Mike Barnet has mentioned this at Microsoft Research and the solution is to add a command line parameter like this: /targetplatform:v4,<path to your v4 framework directory>
So where is the v4 framework directory?
It is located in “C:\Windows\Microsoft.NET\Framework\v4.0.30319” provided you have a default installation.
So I added the command line parameter like this
/targetplatform:v4“C:\Windows\Microsoft.NET\Framework\v4.0.30319”
Make sure that you don’t have a space between the version and the path. It actually caused a stack overflow on my machine :)
Anyway this worked very well and no more complaints about unresolved assemblies.
That was until I tried to merge an assembly that referenced the PresentationCore.dll.
Unresolved assembly reference..again.
What now?
After some investigation I found out that PresentationCore.dll is not located in “C:\Windows\Microsoft.NET\Framework\v4.0.30319”, but in a WPF subfolder.
Aha, that must be it.
The trick here is that the path to the framework should be this
“C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0”
This directory contains all the framework assemblies including PresentationCore.dll
So I changed the command line parameter to
/targetplatform:v4“C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0”
Suddenly all merging of assemblies succeeded.
1 comment:
Shouldn't there be comma between v4 and the path?
Like this:
/targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
Post a Comment