Merge pull request #487 from mayerwin/patch-1
[mono.git] / mcs / class / System / Microsoft.CSharp / CSharpCodeCompiler.cs
index 4c4c943023f6fd16a4835c305e67c29c7c0c1350..26039bdd79b3de87fccd138b2345b4f809967f16 100644 (file)
@@ -78,9 +78,9 @@ namespace Mono.CSharp
                                if (!File.Exists (windowsMonoPath))
                                        throw new FileNotFoundException ("Windows mono path not found: " + windowsMonoPath);
 
-                               windowsMcsPath = Path.Combine (p, "2.0\\mcs.exe");
+                               windowsMcsPath = Path.Combine (p, "4.5\\mcs.exe");
                                if (!File.Exists (windowsMcsPath))
-                                       windowsMcsPath = Path.Combine(Path.GetDirectoryName (p), "lib\\basic\\mcs.exe");
+                                       windowsMcsPath = Path.Combine(Path.GetDirectoryName (p), "lib\\build\\mcs.exe");
                                
                                if (!File.Exists (windowsMcsPath))
                                        throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath);
@@ -178,11 +178,32 @@ namespace Mono.CSharp
 
                        mcsOutput = new StringCollection ();
                        mcsOutMutex = new Mutex ();
-
+#if !NET_4_0
+                       /*
+                        * !:. KLUDGE WARNING .:!
+                        *
+                        * When running the 2.0 test suite some assemblies will invoke mcs via
+                        * CodeDOM and the new mcs process will find the MONO_PATH variable in its
+                        * environment pointing to the net_2_0 library which will cause the runtime
+                        * to attempt to load the 2.0 corlib into 4.0 process and thus mcs will
+                        * fail. At the same time, we must not touch MONO_PATH when running outside
+                        * the test suite, thus the kludge.
+                        *
+                        * !:. KLUDGE WARNING .:!
+                        */
+                       if (Environment.GetEnvironmentVariable ("MONO_TESTS_IN_PROGRESS") != null) {
+                               string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
+                               if (!String.IsNullOrEmpty (monoPath)) {
+                                       monoPath = monoPath.Replace ("/class/lib/net_2_0", "/class/lib/net_4_0");
+                                       mcs.StartInfo.EnvironmentVariables ["MONO_PATH"] = monoPath;
+                               }
+                       }
+#endif
+/*                    
                        string monoPath = Environment.GetEnvironmentVariable ("MONO_PATH");
-                       if (monoPath == null)
+                       if (monoPath != null)
                                monoPath = String.Empty;
-                       
+
                        string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
                        if (privateBinPath != null && privateBinPath.Length > 0)
                                monoPath = String.Format ("{0}:{1}", privateBinPath, monoPath);
@@ -194,7 +215,13 @@ namespace Mono.CSharp
                                else
                                        dict.Add ("MONO_PATH", monoPath);
                        }
-                       
+*/
+                       /*
+                        * reset MONO_GC_PARAMS - we are invoking compiler possibly with another GC that
+                        * may not handle some of the options causing compilation failure
+                        */
+                       mcs.StartInfo.EnvironmentVariables ["MONO_GC_PARAMS"] = String.Empty;
+
                        mcs.StartInfo.CreateNoWindow=true;
                        mcs.StartInfo.UseShellExecute=false;
                        mcs.StartInfo.RedirectStandardOutput=true;
@@ -254,7 +281,7 @@ namespace Mono.CSharp
                                        using (FileStream fs = File.OpenRead(options.OutputAssembly)) {
                                                byte[] buffer = new byte[fs.Length];
                                                fs.Read(buffer, 0, buffer.Length);
-                                               results.CompiledAssembly = Assembly.Load(buffer, null, options.Evidence);
+                                               results.CompiledAssembly = Assembly.Load(buffer, null);
                                                fs.Close();
                                        }
                                } else {
@@ -354,8 +381,10 @@ namespace Mono.CSharp
                                                break;
                                }
                        }
-                       
-#if NET_4_0
+
+#if NET_4_5                    
+                       args.Append("/sdk:4.5");
+#elif NET_4_0
                        args.Append("/sdk:4");
 #else
                        args.Append("/sdk:2");