Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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;
            }
        }
Exemple #5
0
        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;
            }
        }
Exemple #6
0
 protected abstract bool CompileSingle(AbstractBaseGenerator gen, Dictionary<string, string> buildProps, string workingPath, string target);
Exemple #7
0
 protected abstract bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target);
Exemple #8
0
 protected abstract bool CompileSingle(Engine engine, AbstractBaseGenerator gen, string workingPath, string target);