internal class CSharpCodeCompiler : CSharpCodeGenerator, ICodeCompiler
{
- static string windowsMcsPath;
- static string windowsMonoPath;
- static string unixMcsCommand;
-
Mutex mcsOutMutex;
StringCollection mcsOutput;
- static CSharpCodeCompiler ()
- {
- if (Path.DirectorySeparatorChar == '\\') {
- PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic);
- MethodInfo get_gac = gac.GetGetMethod (true);
- string p = Path.GetDirectoryName (
- (string) get_gac.Invoke (null, null));
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.bat");
- if (!File.Exists (windowsMonoPath))
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.exe");
- if (!File.Exists (windowsMonoPath))
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p))),
- "mono\\mono\\mini\\mono.exe");
- if (!File.Exists (windowsMonoPath))
- throw new FileNotFoundException ("Windows mono path not found: " + windowsMonoPath);
-
- windowsMcsPath = Path.Combine (p, "4.5\\mcs.exe");
- if (!File.Exists (windowsMcsPath))
- windowsMcsPath = Path.Combine(Path.GetDirectoryName (p), "lib\\build\\mcs.exe");
-
- if (!File.Exists (windowsMcsPath))
- throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath);
- } else {
- var mscorlibPath = new Uri (typeof (object).Assembly.CodeBase).LocalPath;
- var unixMcsPath = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "mcs"));
- if (File.Exists (unixMcsPath))
- unixMcsCommand = unixMcsPath;
- else
- unixMcsCommand = "mcs";
- }
- }
-
//
// Constructors
//
// FIXME: these lines had better be platform independent.
if (Path.DirectorySeparatorChar == '\\') {
- mcs.StartInfo.FileName = windowsMonoPath;
- mcs.StartInfo.Arguments = "\"" + windowsMcsPath + "\" " +
- BuildArgs (options, fileNames, ProviderOptions);
+ mcs.StartInfo.FileName = MonoExeLocator.MonoPath;
+ mcs.StartInfo.Arguments = "\"" + MonoExeLocator.McsPath + "\" ";
} else {
- mcs.StartInfo.FileName=unixMcsCommand;
- mcs.StartInfo.Arguments=BuildArgs(options, fileNames, ProviderOptions);
+ mcs.StartInfo.FileName = MonoExeLocator.McsPath;
}
+ mcs.StartInfo.Arguments += BuildArgs (options, fileNames, ProviderOptions);
+
mcsOutput = new StringCollection ();
mcsOutMutex = new Mutex ();
/*