From c59b0103ab05c01959deef494ab41e317ec97897 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 18 Sep 2016 16:45:17 +0200 Subject: [PATCH] Adding some new build files for Linux native build --- BuildFiles/Building/MsBuildToCCNet/Logger.cs | 241 ++++++++++++++++++ .../MsBuildToCCNet/MsBuildToCCNet.csproj | 67 +++++ .../MsBuildToCCNet/MsBuildToCCnet.sln | 22 ++ BuildFiles/Building/MsBuildToCCNet/Project.cs | 116 +++++++++ .../MsBuildToCCNet/Properties/AssemblyInfo.cs | 32 +++ BuildFiles/Building/MsBuildToCCNet/README.md | 6 + .../MsBuildToCCNet/ccnet/cruisecontrol.css | 109 ++++++++ .../MsBuildToCCNet/ccnet/msbuild2ccnet.xsl | 51 ++++ BuildFiles/Building/scripts/prebuild-fixes | 8 + 9 files changed, 652 insertions(+) create mode 100644 BuildFiles/Building/MsBuildToCCNet/Logger.cs create mode 100644 BuildFiles/Building/MsBuildToCCNet/MsBuildToCCNet.csproj create mode 100644 BuildFiles/Building/MsBuildToCCNet/MsBuildToCCnet.sln create mode 100644 BuildFiles/Building/MsBuildToCCNet/Project.cs create mode 100644 BuildFiles/Building/MsBuildToCCNet/Properties/AssemblyInfo.cs create mode 100644 BuildFiles/Building/MsBuildToCCNet/README.md create mode 100644 BuildFiles/Building/MsBuildToCCNet/ccnet/cruisecontrol.css create mode 100644 BuildFiles/Building/MsBuildToCCNet/ccnet/msbuild2ccnet.xsl create mode 100755 BuildFiles/Building/scripts/prebuild-fixes diff --git a/BuildFiles/Building/MsBuildToCCNet/Logger.cs b/BuildFiles/Building/MsBuildToCCNet/Logger.cs new file mode 100644 index 00000000..9e0421a5 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/Logger.cs @@ -0,0 +1,241 @@ +// Copyright © 2006 by Christian Rodemeyer (mailto:christian@atombrenner.de) + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System.IO; +using System.Collections; + +namespace Rodemeyer.MsBuildToCCNet +{ + /// + /// Implements a custom MSBuild logger for integration into CruiseControl.NET + /// The following MSBuild verbosity options (/v:) are supported + /// - Quiet => errors, warnings and number of projects build + /// - Minimal => errors, warnings, one entry for every project + /// - Normal => like Minimal plus messages with high importance + /// - Detailed => like Normal plus messages with normal importance + /// - Diagnostic => like Detailed plus messages with low importance + /// + public class MsBuildToCCNetLogger : Logger + { + public MsBuildToCCNetLogger() + { } + + private string logfile; + private string commonPrefix; + + private string currentSolution = null; + + private int commonPrefixLength; + MessageImportance loglevel; + + private Dictionary file_to_project = new Dictionary(); + private Stack project_stack = new Stack(); + private List projects = new List(); + private Project current_project; + + /// + /// called by MSBuild just before starting the build + /// + /// + public override void Initialize(IEventSource eventSource) + { + if (base.Parameters != null) + this.logfile = base.Parameters.Split(';')[0]; // ignore all parameters but the first (which is the name of the file to log to) + else + this.logfile = "msbuild-output.xml"; // default, in case we are not startet from a ccnet task + + this.commonPrefix = Environment.CurrentDirectory; + this.commonPrefixLength = commonPrefix.Length + 1; + + current_project = new Project("MSBuild"); + projects.Add(current_project); + project_stack.Push(current_project); + + if (this.Verbosity > LoggerVerbosity.Minimal) + { + eventSource.MessageRaised += new BuildMessageEventHandler(OnMessageRaised); + switch (Verbosity) + { + case LoggerVerbosity.Normal: loglevel = MessageImportance.High; break; + case LoggerVerbosity.Detailed: loglevel = MessageImportance.Normal; break; + default: loglevel = MessageImportance.Low; break; + } + } + eventSource.WarningRaised += new BuildWarningEventHandler(OnWarningRaised); + eventSource.ErrorRaised += new BuildErrorEventHandler(OnErrorRaised); + eventSource.ProjectStarted += new ProjectStartedEventHandler(OnProjectStarted); + eventSource.ProjectFinished += new ProjectFinishedEventHandler(OnProjectFinished); + } + + /// + /// called by MSBuild after the build has finished + /// + public override void Shutdown() + { + XmlTextWriter w = new XmlTextWriter(logfile, System.Text.Encoding.UTF8); + w.Formatting = this.Verbosity > LoggerVerbosity.Quiet ? Formatting.Indented : Formatting.None; + WriteLog(w); + w.Flush(); + w.Close(); + } + + /// + /// Needed for sorting the project list by number of warnings + /// + class WarningComparer : IComparer + { + public int Compare(Project x, Project y) + { + return y.WarningCount - x.WarningCount; + } + } + + /// + /// writes the in memory gathered information into the xml log file + /// + /// + private void WriteLog(XmlWriter w) + { + w.WriteStartDocument(); + w.WriteStartElement("msbuild"); + if (currentSolution != null) + { + w.WriteAttributeString("solution_name", Path.GetFileName(currentSolution)); + w.WriteAttributeString("solution_dir", Path.GetDirectoryName(currentSolution)); + } + w.WriteAttributeString("project_count", XmlConvert.ToString(projects.Count)); + + int errorCount = 0; + int warningCount = 0; + foreach (Project p in projects) + { + errorCount += p.ErrorCount; + warningCount += p.WarningCount; + } + w.WriteAttributeString("warning_count", XmlConvert.ToString(warningCount)); + w.WriteAttributeString("error_count", XmlConvert.ToString(errorCount)); + buildHasErrors = errorCount > 0; + if (!buildHasErrors) // Sort after WarningCount + { + projects.Sort(new WarningComparer()); + } + foreach (Project p in projects) + { + if (Verbosity > LoggerVerbosity.Quiet || p.ErrorCount > 0 || p.WarningCount > 0) + { + WriteProject(w, p); + } + } + w.WriteEndElement(); + w.WriteEndDocument(); + } + + private bool buildHasErrors; + + /// + /// removes the working folder from the filename + /// + /// + /// + private string RemoveCommonPrefix(string file) + { + if (file.StartsWith(commonPrefix)) + return file.Substring(commonPrefixLength, file.Length - commonPrefixLength); + else + return file; + } + + private void WriteProject(XmlWriter w, Project p) + { + w.WriteStartElement("project"); + string file = RemoveCommonPrefix(p.File); + w.WriteAttributeString("dir", Path.GetDirectoryName(file)); + w.WriteAttributeString("name", Path.GetFileName(file)); + WriteErrorsOrWarnings(w, "error", p.Errors); + if (!buildHasErrors) WriteErrorsOrWarnings(w, "warning", p.Warnings); + WriteMessages(w, p.Messages); + w.WriteEndElement(); + } + + private void WriteErrorsOrWarnings(XmlWriter w, string type, IEnumerable list) + { + foreach (ErrorOrWarningBase ew in list) + { + w.WriteStartElement(type); + w.WriteAttributeString("code", ew.Code); + w.WriteAttributeString("message", ew.Text); + if (ew.File != null) + { + w.WriteAttributeString("dir", Path.GetDirectoryName(ew.File)); + w.WriteAttributeString("name", Path.GetFileName(ew.File)); + w.WriteAttributeString("pos", "(" + XmlConvert.ToString(ew.Line) + ", " + XmlConvert.ToString(ew.Column) + ")"); + } + w.WriteEndElement(); + } + } + + private void WriteMessages(XmlWriter w, IEnumerable list) + { + foreach (Message m in list) + { + w.WriteStartElement("message"); + w.WriteAttributeString("importance", m.Importance.ToString()); + w.WriteString(m.Text); + w.WriteEndElement(); + } + } + + private void OnProjectStarted(object sender, ProjectStartedEventArgs e) + { + if ( (currentSolution == null || currentSolution.EndsWith(".csproj")) && e.ProjectFile.EndsWith(".sln")) + { + currentSolution = RemoveCommonPrefix(e.ProjectFile); + } + + if (currentSolution == null && e.ProjectFile.EndsWith(".csproj")) + { + currentSolution = RemoveCommonPrefix(e.ProjectFile); + } + + if (!file_to_project.TryGetValue(e.ProjectFile, out this.current_project)) + { + current_project = new Project(e.ProjectFile); + file_to_project.Add(e.ProjectFile, current_project); + projects.Add(current_project); + } + project_stack.Push(current_project); + } + + void OnProjectFinished(object sender, ProjectFinishedEventArgs e) + { + project_stack.Pop(); + current_project = (project_stack.Count == 0) ? null : project_stack.Peek(); + } + + private void OnWarningRaised(object sender, BuildWarningEventArgs e) + { + current_project.Add(new Warning(e)); + } + + private void OnErrorRaised(object sender, BuildErrorEventArgs e) + { + current_project.Add(new Error(e)); + } + + private void OnMessageRaised(object sender, BuildMessageEventArgs e) + { + if (e.Importance <= loglevel) + { + current_project.Add(new Message(e)); + } + } + + } + +} diff --git a/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCNet.csproj b/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCNet.csproj new file mode 100644 index 00000000..5fe4ce55 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCNet.csproj @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E9D3235E-2268-4846-B9EC-DFE24AAA438D} + Library + Properties + Rodemeyer.MsBuildToCCnet + Rodemeyer.MsBuildToCCnet.2.0 + + + + + + + + + v2.0 + + + + + 2.0 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + none + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCnet.sln b/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCnet.sln new file mode 100644 index 00000000..a77988d2 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/MsBuildToCCnet.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsBuildToCCNet", "MsBuildToCCNet.csproj", "{E9D3235E-2268-4846-B9EC-DFE24AAA438D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E9D3235E-2268-4846-B9EC-DFE24AAA438D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9D3235E-2268-4846-B9EC-DFE24AAA438D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9D3235E-2268-4846-B9EC-DFE24AAA438D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9D3235E-2268-4846-B9EC-DFE24AAA438D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/BuildFiles/Building/MsBuildToCCNet/Project.cs b/BuildFiles/Building/MsBuildToCCNet/Project.cs new file mode 100644 index 00000000..33272fea --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/Project.cs @@ -0,0 +1,116 @@ +// Copyright © 2006 by Christian Rodemeyer (mailto:christian@atombrenner.de) + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Build.Framework; + +namespace Rodemeyer.MsBuildToCCNet +{ + internal class Project + { + internal Project(string file) + { + File = file; + + errors = new List(); + warnings = new List(); + messages = new List(); + } + + public readonly string File; + + public IEnumerable Errors + { + get { return errors; } + } + private List errors; + + public IEnumerable Warnings + { + get { return warnings; } + } + private List warnings; + + public IEnumerable Messages + { + get { return messages; } + } + private List messages; + + public int ErrorCount + { + get { return errors.Count; } + } + + public int WarningCount + { + get { return warnings.Count; } + } + + public int MessageCount + { + get { return messages.Count; } + } + + public void Add(Error e) + { + errors.Add(e); + } + + public void Add(Warning w) + { + warnings.Add(w); + } + + public void Add(Message m) + { + messages.Add(m); + } + + } + + internal class ErrorOrWarningBase + { + protected ErrorOrWarningBase(string code, string text, string file, int line, int column) + { + Code = code; + Text = text; + File = file == "" ? null : file; + Line = line; + Column = column; + } + + public readonly string Code; + public readonly string Text; + public readonly string File; + public readonly int Line; + public readonly int Column; + } + + internal class Warning: ErrorOrWarningBase + { + public Warning(BuildWarningEventArgs e) + : base (e.Code, e.Message, e.File, e.LineNumber, e.ColumnNumber) + {} + } + + internal class Error : ErrorOrWarningBase + { + public Error(BuildErrorEventArgs e) + : base(e.Code, e.Message, e.File, e.LineNumber, e.ColumnNumber) + {} + } + + internal class Message + { + public Message(BuildMessageEventArgs e) + { + Importance = e.Importance; + Text = e.Message; + } + + public readonly string Text; + public readonly MessageImportance Importance; + } +} diff --git a/BuildFiles/Building/MsBuildToCCNet/Properties/AssemblyInfo.cs b/BuildFiles/Building/MsBuildToCCNet/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..2970e920 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +// Copyright © 2006 by Christian Rodemeyer (mailto:christian@atombrenner.de) + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MsBuildToCCNet")] +[assembly: AssemblyDescription("Custom logger for MSBuild integration into CCNet")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Christian Rodemeyer")] +[assembly: AssemblyProduct("MsBuildLogger")] +[assembly: AssemblyCopyright("Copyright © 2006 by Christian Rodemeyer")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM componenets. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.0.4")] diff --git a/BuildFiles/Building/MsBuildToCCNet/README.md b/BuildFiles/Building/MsBuildToCCNet/README.md new file mode 100644 index 00000000..fd5d5464 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/README.md @@ -0,0 +1,6 @@ +# MsBuildToCCNet +The Rodemeyer.MsBuildToCCnet.dll - a better MsBuild logger for CruiseControl.Net + +The original site is now down, so I found the dll on archive.org and put it here. I still think this one is better than the default CruiseControl.NET one. + +Also making slight changes to it. diff --git a/BuildFiles/Building/MsBuildToCCNet/ccnet/cruisecontrol.css b/BuildFiles/Building/MsBuildToCCNet/ccnet/cruisecontrol.css new file mode 100644 index 00000000..fef57147 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/ccnet/cruisecontrol.css @@ -0,0 +1,109 @@ +body, table, form, input, td, th, p, textarea, select +{ + font-family: verdana, helvetica, arial; + font-size: 11px; +} + +a:hover { color:#FC0; } + +.main-panel { color:#FC0; } + +.link { color:#00F; } +.buildresults-header { color: #000; font-weight: bold; } +.buildresults-data { color: #000; } +.buildresults-data-failed { color: #F30; } + +.stylesection { margin-left: 4px; } +.header-title { font-size:12px; color:#000; font-weight:bold; padding-bottom:10pt; } +.header-label { font-weight:bold; } +.header-data { color:#000; } +.header-data-error { color:#000; white-space:pre; } + +.section-table { margin-top:10px; } +.sectionheader { background-color:#227; color:#FFF; } +.section-data { font-size:9px; color:#000; } +.section-oddrow { background-color:#F0F7FF; } +.section-evenrow { background-color:#FFF; } + +.section-project { font-size:11px; color:black; padding-top:8px; } +.section-error { font-size:10px; color:red; white-space:nowrap; } +.section-warning { font-size:10px; color:orange; white-space:nowrap; } + +.warning { color:orange } +.error { color:red } + +.RecentBuildsPanel { + border-style: solid; + border-width: 1px; + border-color: #333399; + margin-bottom:5; +} + +.RecentBuildsPanel th +{ + background-color: #333399; + text-align: center; + font-weight: bold; + padding: 3px; + color: ivory; +} + +.RecentBuildsPanel td { + padding: 3; + background-color: white; +} + +.breadcrumbs +{ + color: darkgrey; +} +.breadcrumbs a { + color: ivory; + text-decoration: none; +} + +.breadcrumbs a:hover +{ + color:#FC0; +} + +.ProjectGridHeader +{ + color: ivory; +} +.ProjectGridHeader a { + color: ivory; + text-decoration: none; +} +.ProjectGridHeader a:hover +{ + color:#FC0; +} + +.SideBar a +{ + text-decoration: none; + color: #333399; +} + +.SideBar .build-passed-link { color:Green; text-decoration:none; } +.SideBar .build-failed-link { color:Red; text-decoration:none; } + +.build-passed-link { color:Green; text-decoration:none; } +.build-failed-link { color:Red; text-decoration:none; } + +.log +{ + overflow: auto; +} + +.wholepage +{ + background-color: #000066; +} + +.TopControls +{ + background-color: #333399; + color: ivory; +} \ No newline at end of file diff --git a/BuildFiles/Building/MsBuildToCCNet/ccnet/msbuild2ccnet.xsl b/BuildFiles/Building/MsBuildToCCNet/ccnet/msbuild2ccnet.xsl new file mode 100644 index 00000000..33ca3331 --- /dev/null +++ b/BuildFiles/Building/MsBuildToCCNet/ccnet/msbuild2ccnet.xsl @@ -0,0 +1,51 @@ + + + + + + + + + + + + + +
+ in : + + + Build failed with errors + + + Projects built with warnings + + + Projects built with no warnings at all :-) + + +
Happy Image :-) Juchuu !!!
+
+ + + + + in : + + + + + + section-error + section-warning + + + + + + + + : in
+
+ +
diff --git a/BuildFiles/Building/scripts/prebuild-fixes b/BuildFiles/Building/scripts/prebuild-fixes new file mode 100755 index 00000000..7585a61f --- /dev/null +++ b/BuildFiles/Building/scripts/prebuild-fixes @@ -0,0 +1,8 @@ +#!/bin/bash + +find . -iname 'Pages*.resx' -exec rename 's/Pages\.([A-Za-z_\.\-]+)\.resx/Pages_$1\.resx/' {} \; +find . -iname 'Controls*.resx' -exec rename 's/Controls\.([A-Za-z_\.\-]+)\.resx/Controls_$1\.resx/' {} \; + +find . -iname '*.cs' -exec perl -pi -e 's/Resources.Pages.([A-Za-z\.]+)/Resources.Pages_$1/g;' {} \; +find . -iname '*.cs' -exec perl -pi -e 's/Resources.Controls.([A-Za-z\.]+)/Resources.Controls_$1/g;' {} \; +