private void Compile() { Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = Options.CompilerName; p.StartInfo.Arguments = String.Format( "-target:library -out:\"{0}/{1}\" -lib:\"{2}\" -reference:GNU.Gettext.dll -optimize+ \"{3}\"", AssemblyOutDir, GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName), Path.GetFullPath(Options.LibDir), CsharpSourceFileName ); if (Options.Verbose) { Console.WriteLine("Compiler: {0} {1}", p.StartInfo.FileName, p.StartInfo.Arguments); } p.Start(); p.WaitForExit(30000); if (p.HasExited) { if (p.ExitCode != 0) { throw new Exception(String.Format( "Assembly compilation failed. ExitCode: {0}\nSee source file: {1}\n{2}\n{3}", p.ExitCode, CsharpSourceFileName, p.StandardOutput.ReadToEnd(), p.StandardError.ReadToEnd())); } } else { p.Close(); p.Kill(); throw new Exception("Assembly compilation timeout"); } }
private void Compile() { if (File.Exists(GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName))) { File.Delete(GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName)); } CompilerParameters cp = new CompilerParameters(); cp.GenerateExecutable = false; cp.OutputAssembly = GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName); cp.IncludeDebugInformation = false; cp.ReferencedAssemblies.Add("GNU.Gettext.dll"); cp.GenerateInMemory = false; cp.CompilerOptions = "-optimize+"; CSharpCodeProvider Compiler = new CSharpCodeProvider(new Dictionary <string, string>() { { "CompilerVersion", "v3.5" } }); CompilerResults cr = Compiler.CompileAssemblyFromFile(cp, CsharpSourceFileName); if (!cr.Errors.HasErrors) { if (File.Exists(Path.Combine(AssemblyOutDir, GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName)))) { File.Delete(Path.Combine(AssemblyOutDir, GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName))); } File.Move(GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName), Path.Combine(AssemblyOutDir, GettextResourceManager.GetSatelliteAssemblyName(Options.BaseName))); } else { String error = "Assembly compilation failed."; foreach (CompilerError er in cr.Errors) { error += "\n" + cr.Output; } throw new Exception(error); } }