Fix bugs #323833 and #484384.
authorAnkit Jain <radical@corewars.org>
Thu, 19 Mar 2009 01:09:56 +0000 (01:09 -0000)
committerAnkit Jain <radical@corewars.org>
Thu, 19 Mar 2009 01:09:56 +0000 (01:09 -0000)
* AssemblyResolver.cs (GatherGacAssemblies): Handle duplicate entries.
These seem to be old copies of the assemblies with old keys. Pick
the one with the latest timestamp.

svn path=/trunk/mcs/; revision=129760

mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog

index 8c4f9577364470dd454a8dac7d82172b3d63bf7b..212f427baf999fa74171292a15d9995c8ca7b6dd 100644 (file)
@@ -94,9 +94,19 @@ namespace Microsoft.Build.Tasks {
                                                version = new Version (version_info.Name.Split (
                                                        new char [] {'_'}, StringSplitOptions.RemoveEmptyEntries) [0]);
 
-                                               if (!gac.ContainsKey (assembly_info.Name))
-                                                       gac.Add (assembly_info.Name, new Dictionary <Version, string> ());
-                                               gac [assembly_info.Name].Add (version, file);
+                                               Dictionary<Version, string> assembliesByVersion = new Dictionary <Version, string> ();
+                                               if (!gac.TryGetValue (assembly_info.Name, out assembliesByVersion)) {
+                                                       assembliesByVersion = new Dictionary <Version, string> ();
+                                                       gac.Add (assembly_info.Name, assembliesByVersion);
+                                               }
+
+                                               string found_file;
+                                               if (assembliesByVersion.TryGetValue (version, out found_file) &&
+                                                       File.GetLastWriteTime (file) <= File.GetLastWriteTime (found_file))
+                                                               // Duplicate found, take the newer file
+                                                               continue;
+
+                                               assembliesByVersion [version] = file;
                                        }
                                }
                        }
index 42f7c41e4e5d858c8b058c0e22a51293cf96acbc..a9fcca1d1dc0ef43a64a1ce18400f8f19fb3a55f 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-19  Ankit Jain  <jankit@novell.com>
+
+       Fix bugs #323833 and #484384.
+       * AssemblyResolver.cs (GatherGacAssemblies): Handle duplicate entries.
+       These seem to be old copies of the assemblies with old keys. Pick
+       the one with the latest timestamp.
+
 2009-03-03  Ankit Jain  <jankit@novell.com>
 
        Fix bug #480856.