protected override bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target) { try { using (log4net.NDC.Push("Compiling " + gen.Description)) { Log.DebugFormat("Loading MsBuild Project"); var proj = new Project(engine); proj.Load(Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName)); Log.DebugFormat("Compiling"); if (engine.BuildProject(proj, target)) { return(true); } else { Log.ErrorFormat("Failed to compile {0}", gen.Description); return(false); } } } catch (Exception ex) { Log.Error("Failed compiling " + gen.Description, ex); return(false); } }
protected override bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target) { try { using (log4net.NDC.Push("Compiling " + gen.Description)) { Log.DebugFormat("Loading MsBuild Project"); var proj = new Project(engine); proj.Load(Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName)); Log.DebugFormat("Compiling"); if (engine.BuildProject(proj, target)) { return true; } else { Log.ErrorFormat("Failed to compile {0}", gen.Description); return false; } } } catch (Exception ex) { Log.Error("Failed compiling " + gen.Description, ex); return false; } }
protected override bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target) { try { using (log4net.NDC.Push("Compiling " + gen.Description)) { var props = String.Join(";", engine.GlobalProperties.OfType <BuildProperty>().Select(prop => String.Format("{0}={1}", prop.Name, prop.Value)).ToArray()); var args = String.Format("\"/p:{0}\" {1}", props, Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName)); var pi = new ProcessStartInfo("xbuild", args); pi.UseShellExecute = false; pi.RedirectStandardOutput = true; pi.RedirectStandardError = true; pi.ErrorDialog = false; pi.CreateNoWindow = true; Log.InfoFormat("Calling xbuild with arguments [{0}]", args); var p = Process.Start(pi); p.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => { if (!String.IsNullOrEmpty(e.Data)) { Log.Error(e.Data); } }; p.BeginErrorReadLine(); p.OutputDataReceived += (object sender, DataReceivedEventArgs e) => { if (!String.IsNullOrEmpty(e.Data)) { Log.Info(e.Data); } }; p.BeginOutputReadLine(); if (!p.WaitForExit(100 * 1000)) { p.Kill(); throw new InvalidOperationException(String.Format("xbuild did not complete within 100 seconds")); } return(p.ExitCode == 0); } } catch (Exception ex) { Log.Error("Failed compiling " + gen.Description, ex); return(false); } }
protected override bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target) { try { using (log4net.NDC.Push("Compiling " + gen.Description)) { var props = String.Join(";", engine.GlobalProperties.OfType<BuildProperty>().Select(prop => String.Format("{0}={1}", prop.Name, prop.Value)).ToArray()); var args = String.Format("\"/p:{0}\" {1}", props, Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName)); var pi = new ProcessStartInfo("xbuild", args); pi.UseShellExecute = false; pi.RedirectStandardOutput = true; pi.RedirectStandardError = true; pi.ErrorDialog = false; pi.CreateNoWindow = true; Log.InfoFormat("Calling xbuild with arguments [{0}]", args); var p = Process.Start(pi); p.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => { if (!String.IsNullOrEmpty(e.Data)) Log.Error(e.Data); }; p.BeginErrorReadLine(); p.OutputDataReceived += (object sender, DataReceivedEventArgs e) => { if (!String.IsNullOrEmpty(e.Data)) Log.Info(e.Data); }; p.BeginOutputReadLine(); if (!p.WaitForExit(100 * 1000)) { p.Kill(); throw new InvalidOperationException(String.Format("xbuild did not complete within 100 seconds")); } return p.ExitCode == 0; } } catch (Exception ex) { Log.Error("Failed compiling " + gen.Description, ex); return false; } }
protected override bool CompileSingle(AbstractBaseGenerator gen, Dictionary<string, string> buildProps, string workingPath, string target) { try { using (log4net.NDC.Push("Compiling " + gen.Description)) { Log.DebugFormat("Loading MsBuild Project"); var projectFile = Helper.PathCombine(workingPath, gen.TargetNameSpace, gen.ProjectFileName); var req = new BuildRequestData( projectFile, buildProps, null, new[] { target }, null); var logger = new Microsoft.Build.Logging.ConsoleLogger(LoggerVerbosity.Minimal); var buildParameter = new BuildParameters(); buildParameter.Loggers = new List<ILogger>() { logger }; Log.DebugFormat("Compiling"); var result = BuildManager.DefaultBuildManager.Build(buildParameter, req); if (result.OverallResult == BuildResultCode.Success) { return true; } else { Log.ErrorFormat("Failed to compile {0}", gen.Description); return false; } } } catch (Exception ex) { Log.Error("Failed compiling " + gen.Description, ex); return false; } }
protected abstract bool CompileSingle(AbstractBaseGenerator gen, Dictionary<string, string> buildProps, string workingPath, string target);
protected abstract bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target);