/// <summary> /// Performs additional checks after the task has been initialized. /// </summary> /// <exception cref="BuildException"><see cref="FileName" /> does not hold a valid file name.</exception> protected override void Initialize() { base.Initialize(); ErrorWriter = new ScanningTextWriter(this, _includeErrorPatterns, _excludeErrorPatterns); OutputWriter = new ScanningTextWriter(this, _includeErrorPatterns, _excludeErrorPatterns); }
/// <summary> /// Executes the external program. /// </summary> protected override void ExecuteTask() { Exception theEx = null; try { base.ExecuteTask(); if (ResultProperty != null) { Properties[ResultProperty] = base.ExitCode.ToString( CultureInfo.InvariantCulture); } } catch (Exception ex) { theEx = ex; } finally { ScanningTextWriter err = (ScanningTextWriter)ErrorWriter; ScanningTextWriter outw = (ScanningTextWriter)OutputWriter; if (!string.IsNullOrEmpty(err.Errors) || !string.IsNullOrEmpty(outw.Errors)) { string errMsg = "Critical errors found during the execution of : " + ExeName + " " + CommandLine + ":" + Environment.NewLine; errMsg += err.Errors; errMsg += outw.Errors; if (ResultProperty != null) { Properties[ResultProperty] = FailedExitCode.ToString(); } throw new BuildException(errMsg, theEx); } else if (theEx != null) { throw new BuildException("UnKnown Build Error:", theEx); } } }