Do not remap framework assembly if it's version is higher than the runtime version
authorAnkit Jain <ankit.jain@xamarin.com>
Tue, 23 Feb 2016 21:03:48 +0000 (16:03 -0500)
committerAnkit Jain <ankit.jain@xamarin.com>
Wed, 9 Mar 2016 20:37:12 +0000 (15:37 -0500)
Currently, assemblies like Microsoft.Build.Framework and
Microsoft.Build.Engine get remapped to the current runtime version, at
load time. This means that if an assembly references the above
assemblies with a version like `14.1.0.0`, then that would get remapped
to `4.0.0.0`. This is incorrect behavior and breaks msbuild. Instead,
now we do the remapping only if the requested version is lower than the
runtime version.

@akoplinger: This will actually impact xbuild too right now because
we're defaulting to xbuild 14.0 in Mono 4.4 now so we'd see messages
like Mono: The request to load the assembly Microsoft.Build.Framework
v14.0.0.0 was remapped to v4.0.0.0 in the assembly loading log, which
will break in very subtle ways.

mono/metadata/assembly.c

index 7785abeafa9b643d5d4959a2477969956d0fe4e8..db17fabc1b2c803912aebf33938fc99b3f45dba9 100644 (file)
@@ -1016,6 +1016,12 @@ mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_ana
                        if (aname->major == vset->major && aname->minor == vset->minor &&
                                aname->build == vset->build && aname->revision == vset->revision)
                                return aname;
+
+                       if (compare_versions (vset, aname) < 0) {
+                               // requested version is newer than current
+                               // runtime version, don't remap
+                               return aname;
+                       }
                
                        if ((aname->major | aname->minor | aname->build | aname->revision) != 0)
                                mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,