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);
#if NET_2_0
windowsMcsPath =
Path.Combine (p, "2.0\\gmcs.exe");
windowsMcsPath =
Path.Combine (p, "1.0\\mcs.exe");
#endif
+ if (!File.Exists (windowsMcsPath))
+#if NET_2_0
+ windowsMcsPath =
+ Path.Combine(
+ Path.GetDirectoryName (p),
+ "lib\\net_2_0\\gmcs.exe");
+#else
+ windowsMcsPath =
+ Path.Combine(
+ Path.GetDirectoryName (p),
+ "lib\\default\\mcs.exe");
+#endif
+ if (!File.Exists (windowsMcsPath))
+ throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath);
}
}
Process mcs=new Process();
string mcs_output;
+ string mcs_stdout;
string[] mcs_output_lines;
// FIXME: these lines had better be platform independent.
if (Path.DirectorySeparatorChar == '\\') {
mcs.StartInfo.FileName = windowsMonoPath;
- mcs.StartInfo.Arguments = windowsMcsPath + ' ' + BuildArgs (options, fileNames);
- }
- else {
+ mcs.StartInfo.Arguments = "\"" + windowsMcsPath + "\" " + BuildArgs (options, fileNames);
+ } else {
#if NET_2_0
// FIXME: This is a temporary hack to make code genaration work in 2.0
mcs.StartInfo.FileName="gmcs";
mcs.Start();
// If there are a few kB in stdout, we might lock
mcs_output=mcs.StandardError.ReadToEnd();
- mcs.StandardOutput.ReadToEnd ();
+ mcs_stdout=mcs.StandardOutput.ReadToEnd ();
mcs.WaitForExit();
- } finally {
results.NativeCompilerReturnValue = mcs.ExitCode;
+ } finally {
mcs.Close();
}
mcs_output_lines=mcs_output.Split(
}
}
if (loadIt) {
+ if (!File.Exists (options.OutputAssembly)) {
+ throw new Exception ("Compiler failed to produce the assembly. Stderr='"
+ +mcs_output+"', Stdout='"+mcs_stdout+"'");
+ }
if (options.GenerateInMemory) {
using (FileStream fs = File.OpenRead(options.OutputAssembly)) {
byte[] buffer = new byte[fs.Length];
options.OutputAssembly = GetTempFileNameWithExtension (options.TempFiles, "dll", !options.GenerateInMemory);
args.AppendFormat("/out:\"{0}\" ",options.OutputAssembly);
- if (null != options.ReferencedAssemblies)
- {
- foreach (string import in options.ReferencedAssemblies)
- args.AppendFormat("/r:\"{0}\" ",import);
+ foreach (string import in options.ReferencedAssemblies) {
+ if (import == null || import.Length == 0)
+ continue;
+
+ args.AppendFormat("/r:\"{0}\" ",import);
}
if (options.CompilerOptions != null) {
args.Append (options.CompilerOptions);
args.Append (" ");
}
-
+
+#if NET_2_0
+ foreach (string embeddedResource in options.EmbeddedResources) {
+ args.AppendFormat("/resource:\"{0}\" ", embeddedResource);
+ }
+
+ foreach (string linkedResource in options.LinkedResources) {
+ args.AppendFormat("/linkresource:\"{0}\" ", linkedResource);
+ }
+#endif
+
args.Append (" -- ");
foreach (string source in fileNames)
args.AppendFormat("\"{0}\" ",source);
if (error_string.StartsWith ("BETA"))
return null;
#endif
+ if (error_string == null || error_string == "")
+ return null;
CompilerError error=new CompilerError();
- Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)\s+)*(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
+ Regex reg = new Regex (@"^(\s*(?<file>.*)\((?<line>\d*)(,(?<column>\d*))?\)(:)?\s+)*(?<level>\w+)\s*(?<number>.*):\s(?<message>.*)",
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
Match match=reg.Match(error_string);
if (!match.Success) return null;
CodeCompileUnit compileUnit = ea[i];
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
- StreamWriter s = new StreamWriter (f);
+ StreamWriter s = new StreamWriter (f, Encoding.UTF8);
if (compileUnit.ReferencedAssemblies != null) {
foreach (string str in compileUnit.ReferencedAssemblies) {
if (!assemblies.Contains (str))
for (int i = 0; i < sources.Length; i++) {
fileNames[i] = GetTempFileNameWithExtension (options.TempFiles, i + ".cs");
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
- using (StreamWriter s = new StreamWriter (f)) {
+ using (StreamWriter s = new StreamWriter (f, Encoding.UTF8)) {
s.Write (sources[i]);
s.Close ();
}