/// <summary>
        /// Transform the devenv output streams into an XML build report fragment and return it.
        /// </summary>
        /// <param name="devenvOutput">devenv's standard output with platform-specific newlines</param>
        /// <param name="devenvError">devenv's standard error with platform-specific newlines</param>
        /// <returns>the resulting build report fragment</returns>
        private static string TransformDevenvOutput(string devenvOutput, string devenvError,TaskBase task)
		{
			StringWriter output = new StringWriter();
			XmlWriter writer = new XmlTextWriter(output);
			writer.WriteStartElement("buildresults");

            if (task != null)
            {
                new ReflectorTypeAttribute("task").Write(writer, task);
            }

			WriteContent(writer, devenvOutput, false);
            WriteContent(writer, devenvError, true);
            writer.WriteEndElement();
			return output.ToString();
		}
        /// <summary>
        /// Convert a stream of text lines separated with newline sequences into an XML build result.
        /// </summary>
        /// <param name="input">the text stream</param>
        /// <param name="msgLevel">the message level, if any.  Values are "Error" and "Warning".</param>
        /// <param name="task">the task to serialize alongside the result, if any</param>
        /// <returns>the build result string</returns>
        /// <remarks>If there are any non-blank lines in the input, they are each wrapped in a
        /// <code>&lt;message&gt;</code> element and the entire set is wrapped in a
        /// <code>&lt;buildresults&gt;</code> element and returned.  Each line of the input is encoded
        /// as XML CDATA rules require.  If the input is empty or contains only whitspace, an 
        /// empty string is returned.
        /// Note: If we can't manage to understand the input, we just return it unchanged.
        /// </remarks>
        public static string MakeBuildResult(string input, string msgLevel, TaskBase task)
        {
            StringBuilder sb = new StringBuilder();

            // Pattern for capturing a line of text, exclusive of the line-ending sequence.
            // A "line" is an non-empty unbounded sequence of characters followed by some 
            // kind of line-ending sequence (CR, LF, or any combination thereof) or 
            // end-of-string.
            Regex linePattern = new Regex(@"([^\r\n]+)");

            MatchCollection lines = linePattern.Matches(input);
            if (lines.Count > 0)
            {
                sb.Append(Environment.NewLine);
                sb.Append("<buildresults>");
                sb.Append(Environment.NewLine);

                if (task != null)
                {
                    StringWriter buffer = new StringWriter();
                    new ReflectorTypeAttribute("task").Write(new XmlTextWriter(buffer), task);
                    sb.Append(buffer.ToString());
                    sb.Append(Environment.NewLine);
                }

                foreach (Match line in lines)
                {
                    sb.Append("  <message");
                    if (!(msgLevel != null && msgLevel.Length == 0))
                        sb.AppendFormat(CultureInfo.CurrentCulture, " level=\"{0}\"", msgLevel);
                    sb.Append(">");
                    sb.Append(XmlUtil.EncodePCDATA(line.ToString()));
                    sb.Append("</message>");
                    sb.Append(Environment.NewLine);
                }
                sb.Append("</buildresults>");
                sb.Append(Environment.NewLine);
            }
            else
                sb.Append(input); // All of that stuff failed, just return our input
            return sb.ToString();
        }
Example #3
0
        /// <summary>
        /// Transform the devenv output streams into an XML build report fragment and return it.
        /// </summary>
        /// <param name="devenvOutput">devenv's standard output with platform-specific newlines</param>
        /// <param name="devenvError">devenv's standard error with platform-specific newlines</param>
        /// <returns>the resulting build report fragment</returns>
        private static string TransformDevenvOutput(string devenvOutput, string devenvError, TaskBase task)
        {
            StringWriter output = new StringWriter();
            XmlWriter    writer = new XmlTextWriter(output);

            writer.WriteStartElement("buildresults");

            if (task != null)
            {
                new ReflectorTypeAttribute("task").Write(writer, task);
            }

            WriteContent(writer, devenvOutput, false);
            WriteContent(writer, devenvError, true);
            writer.WriteEndElement();
            return(output.ToString());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DevenvTaskResult" /> class.	
        /// </summary>
        /// <param name="result">The result.</param>
        /// <remarks></remarks>
		public DevenvTaskResult(ProcessResult result,TaskBase task) :
            base(result) { _task = task; }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DevenvTaskResult" /> class.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <remarks></remarks>
 public DevenvTaskResult(ProcessResult result, TaskBase task) :
     base(result)
 {
     _task = task;
 }