我想知道如何BuildResult
在运行时构建 C# 项目后得到错误。
目前我有这个:
string projectFileName = @"C:\Users\Inspire\Documents\Mono Projects\Library\Library\Library.csproj";
FileLogger fileLogger = new FileLogger();
fileLogger.Parameters = @"logfile=" + @"C:\Users\Inspire\Documents\Mono Projects\Library\Library\log.text";
ProjectCollection projectCollection = new ProjectCollection();
projectCollection.RegisterLogger(fileLogger);
Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();
GlobalProperty.Add("Configuration", "Debug");
GlobalProperty.Add("Platform", "x86");
BuildRequestData buildRequest = new BuildRequestData(projectFileName, GlobalProperty, null, new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(projectCollection), buildRequest);
projectCollection.UnregisterAllLoggers();
Console.WriteLine(buildResult.OverallResult.ToString());
/* TODO: handle errors */
我想知道错误,以便在构建后处理它们(这里是注释部分“处理错误”),FileLogger
如您所见,我添加了一个文件,但该文件始终为空(有或没有错误)。
谢谢