public MSBuildResult[] RunTarget(string target, ProjectConfigurationInfo[] configurations, ILogWriter logWriter, MSBuildVerbosity verbosity) { MSBuildResult[] result = null; BuildEngine.RunSTA(delegate { try { var project = SetupProject(configurations); currentLogWriter = logWriter; var logger = new LocalLogger(file); buildEngine.Engine.UnregisterAllLoggers(); buildEngine.Engine.RegisterLogger(logger); buildEngine.Engine.RegisterLogger(consoleLogger); consoleLogger.Verbosity = GetVerbosity(verbosity); // We are using this BuildProject overload and the BuildSettings.None argument as a workaround to // an xbuild bug which causes references to not be resolved after the project has been built once. buildEngine.Engine.BuildProject(project, new [] { target }, new Hashtable(), BuildSettings.None); result = logger.BuildResult.ToArray(); } catch (InvalidProjectFileException ex) { var r = new MSBuildResult( file, false, ex.ErrorSubcategory, ex.ErrorCode, ex.ProjectFile, ex.LineNumber, ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, ex.BaseMessage, ex.HelpKeyword); logWriter.WriteLine(r.ToString()); result = new [] { r }; } finally { currentLogWriter = null; } }); return(result); }
public MSBuildResult[] RunTarget(string target, ProjectConfigurationInfo[] configurations, ILogWriter logWriter, MSBuildVerbosity verbosity) { MSBuildResult[] result = null; BuildEngine.RunSTA(delegate { try { var project = SetupProject(configurations); currentLogWriter = logWriter; var logger = new LocalLogger(file); engine.UnregisterAllLoggers(); engine.RegisterLogger(logger); engine.RegisterLogger(consoleLogger); consoleLogger.Verbosity = GetVerbosity(verbosity); project.Build(target); result = logger.BuildResult.ToArray(); } catch (Microsoft.Build.Exceptions.InvalidProjectFileException ex) { var r = new MSBuildResult( file, false, ex.ErrorSubcategory, ex.ErrorCode, ex.ProjectFile, ex.LineNumber, ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, ex.BaseMessage, ex.HelpKeyword); logWriter.WriteLine(r.ToString()); result = new [] { r }; } finally { currentLogWriter = null; } }); return(result); }
public MSBuildResult[] RunTarget (string target, ProjectConfigurationInfo[] configurations, ILogWriter logWriter, MSBuildVerbosity verbosity) { MSBuildResult[] result = null; BuildEngine.RunSTA (delegate { try { var project = SetupProject (configurations); currentLogWriter = logWriter; var logger = new LocalLogger (file); buildEngine.Engine.UnregisterAllLoggers (); buildEngine.Engine.RegisterLogger (logger); buildEngine.Engine.RegisterLogger (consoleLogger); consoleLogger.Verbosity = GetVerbosity (verbosity); // We are using this BuildProject overload and the BuildSettings.None argument as a workaround to // an xbuild bug which causes references to not be resolved after the project has been built once. buildEngine.Engine.BuildProject (project, new [] { target }, new Hashtable (), BuildSettings.None); result = logger.BuildResult.ToArray (); } catch (InvalidProjectFileException ex) { var r = new MSBuildResult ( file, false, ex.ErrorSubcategory, ex.ErrorCode, ex.ProjectFile, ex.LineNumber, ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, ex.BaseMessage, ex.HelpKeyword); logWriter.WriteLine (r.ToString ()); result = new [] { r }; } finally { currentLogWriter = null; } }); return result; }
public MSBuildResult[] RunTarget (string target, ProjectConfigurationInfo[] configurations, ILogWriter logWriter, MSBuildVerbosity verbosity) { MSBuildResult[] result = null; BuildEngine.RunSTA (delegate { try { var project = SetupProject (configurations); currentLogWriter = logWriter; var logger = new LocalLogger (file); engine.UnregisterAllLoggers (); engine.RegisterLogger (logger); engine.RegisterLogger (consoleLogger); consoleLogger.Verbosity = GetVerbosity (verbosity); project.Build (target); result = logger.BuildResult.ToArray (); } catch (Microsoft.Build.Exceptions.InvalidProjectFileException ex) { var r = new MSBuildResult ( file, false, ex.ErrorSubcategory, ex.ErrorCode, ex.ProjectFile, ex.LineNumber, ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, ex.BaseMessage, ex.HelpKeyword); logWriter.WriteLine (r.ToString ()); result = new [] { r }; } finally { currentLogWriter = null; } }); return result; }