예제 #1
0
        /// <summary>
        /// Parses a given error file and translates the data to a list of ErrorWarningCodes objects.
        /// </summary>
        /// <param name="errorfilename"></param>
        /// <returns></returns>
        internal bool Parse(string errorfilename)
        {
            if (errorfilename == null)
            {
                MSBuildEngineCommonHelper.LogDiagnostic = "Error file was not specified";
                return(false);
            }

            try
            {
                XmlDocumentSW doc = new XmlDocumentSW();

                doc.Load(errorfilename);
                if (doc.DocumentElement.Name != Constants.ErrorRootElement)
                {
                    MSBuildEngineCommonHelper.LogError = "Invalid Error codes file.";
                    return(false);
                }

                Parse(doc.DocumentElement);
            }
            catch (XmlException xex)
            {
                MSBuildEngineCommonHelper.DisplayExceptionInformation(xex);
                return(false);
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Build Finished Event handler, logs to build log file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void eventSource_BuildFinishedEvent(object sender, BuildFinishedEventArgs e)
        {
            LogToBuildLog(e.Message);

            if (logmemorystream != null)
            {
                MSBuildEngineCommonHelper.WritetoFilefromMemory(ref logmemorystream, this.buildlogfile);
            }
            if (errormemorystream != null)
            {
                MSBuildEngineCommonHelper.WritetoFilefromMemory(ref errormemorystream, this.builderrorfile);
            }
            if (warningmemorystream != null)
            {
                MSBuildEngineCommonHelper.WritetoFilefromMemory(ref warningmemorystream, this.buildwaringfile);
            }

            projectfilestack = null;
            currentduplicateerrorwarningid = null;
        }
예제 #3
0
        /// <summary>
        /// Overloaded method does the actual logging to file.
        /// </summary>
        /// <param name="message"></param>
        private void LogToBuildLog(string message)
        {
            MSBuildEngineCommonHelper.Log = message;
            if (String.IsNullOrEmpty(buildlogfile))
            {
                return;
            }

            MSBuildEngineCommonHelper.SaveToMemory(message, ref logmemorystream, buildlogfile);
            //buildlog = new StreamWriter(buildlogfile, true);
            //if (String.IsNullOrEmpty(message))
            //{
            //    buildlog.WriteLine();
            //}
            //else
            //{
            //    buildlog.WriteLine(message);
            //}

            //buildlog.Close();
            //buildlog = null;
        }
예제 #4
0
        /// <summary>
        /// Log to Build warning file and to Build Log file.
        /// </summary>
        /// <param name="e"></param>
        private void LogToBuildWarning(BuildWarningEventArgs e)
        {
            if (e != null)
            {
                StringBuilder sb            = new StringBuilder();
                StringBuilder tab           = new StringBuilder();
                StringBuilder warningstring = new StringBuilder();

                //if (String.IsNullOrEmpty(buildwaringfile) == false)
                //{
                //    buildwarning = new StreamWriter(buildwaringfile, true);
                //}

                for (int i = 0; i < tabcount; i++)
                {
                    tab.Append("\t");
                }

                //sb.AppendFormat("{0} - ",e.Timestamp.ToString());

                string currentprojfile = null;
                if (projectfilestack.Count > 0)
                {
                    currentprojfile = projectfilestack.Peek().ToString();
                }

                if (e.File != null && e.File.ToLowerInvariant() != currentprojfile)
                {
                    sb.Append(e.File.ToString() + " ");
                    //if (buildwarning != null)
                    //{
                    //						buildwarning.Write(PathSW.GetFullPath(e.File.ToString()) + " ");
                    //buildwarning.Write(currentprojfile + " : " + e.File.ToString() + " ");
                    warningstring.Append(currentprojfile + " : " + e.File.ToString() + " ");
                    //}

                    if (e.LineNumber >= 0 && e.ColumnNumber >= 0)
                    {
                        sb.Append("(" + e.LineNumber + "," + e.ColumnNumber + ") " + " :");
                        //if (buildwarning != null)
                        //{
                        //    buildwarning.Write("(" + e.LineNumber + "," + e.ColumnNumber + ") " + " :");
                        //}
                        warningstring.Append("(" + e.LineNumber + "," + e.ColumnNumber + ") " + " :");
                    }
                }
                else
                {
                    sb.AppendFormat("{0} - :", PathSW.GetFileName(currentprojfile));
                    //if (buildwarning != null)
                    //{
                    //    buildwarning.Write("{0} - :", currentprojfile);
                    //}
                    warningstring.AppendFormat("{0} - :", currentprojfile);
                }

                if (e.Code != null)
                {
                    sb.Append(" warning " + e.Code + ": ");
                    //if (buildwarning != null)
                    //{
                    //    buildwarning.Write(" warning " + e.Code + ": ");
                    //}
                    warningstring.Append(" warning " + e.Code + ": ");
                }

                sb.Append(e.Message);
                //if (buildwarning != null)
                //{
                //    buildwarning.Write(e.Message);
                //    buildwarning.WriteLine();
                //}
                warningstring.Append(e.Message + "\n");

                //if (buildwarning != null)
                //{
                //    //buildwarning.WriteLine(sb.ToString());
                //    buildwarning.Close();
                //    buildwarning = null;
                //}

                if (String.IsNullOrEmpty(buildwaringfile) == false)
                {
                    MSBuildEngineCommonHelper.SaveToMemory(warningstring.ToString(), ref warningmemorystream, buildwaringfile);
                    MSBuildEngineCommonHelper.WritetoFilefromMemory(ref warningmemorystream, buildwaringfile);
                }

                MSBuildEngineCommonHelper.LogWarning = sb.ToString();
                LogToBuildLog(tab.ToString() + sb.ToString());

                sb  = null;
                tab = null;
            }
        }