Adding some new build files for Linux native build

This commit is contained in:
Rick Falkvinge
2016-09-18 16:45:17 +02:00
parent e4d1b9edee
commit c59b0103ab
9 changed files with 652 additions and 0 deletions
@@ -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
{
/// <summary>
/// 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
/// </summary>
public class MsBuildToCCNetLogger : Logger
{
public MsBuildToCCNetLogger()
{ }
private string logfile;
private string commonPrefix;
private string currentSolution = null;
private int commonPrefixLength;
MessageImportance loglevel;
private Dictionary<string, Project> file_to_project = new Dictionary<string, Project>();
private Stack<Project> project_stack = new Stack<Project>();
private List<Project> projects = new List<Project>();
private Project current_project;
/// <summary>
/// called by MSBuild just before starting the build
/// </summary>
/// <param name="eventSource"></param>
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);
}
/// <summary>
/// called by MSBuild after the build has finished
/// </summary>
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();
}
/// <summary>
/// Needed for sorting the project list by number of warnings
/// </summary>
class WarningComparer : IComparer<Project>
{
public int Compare(Project x, Project y)
{
return y.WarningCount - x.WarningCount;
}
}
/// <summary>
/// writes the in memory gathered information into the xml log file
/// </summary>
/// <param name="w"></param>
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;
/// <summary>
/// removes the working folder from the filename
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
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<Message> 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));
}
}
}
}
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E9D3235E-2268-4846-B9EC-DFE24AAA438D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rodemeyer.MsBuildToCCnet</RootNamespace>
<AssemblyName>Rodemeyer.MsBuildToCCnet.2.0</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Project.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Logger.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ccnet\cruisecontrol.css" />
</ItemGroup>
<ItemGroup>
<Content Include="ccnet\msbuild2ccnet.xsl" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
@@ -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
@@ -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<Error>();
warnings = new List<Warning>();
messages = new List<Message>();
}
public readonly string File;
public IEnumerable<Error> Errors
{
get { return errors; }
}
private List<Error> errors;
public IEnumerable<Warning> Warnings
{
get { return warnings; }
}
private List<Warning> warnings;
public IEnumerable<Message> Messages
{
get { return messages; }
}
private List<Message> 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;
}
}
@@ -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")]
@@ -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.
@@ -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;
}
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright © 2006 by Christian Rodemeyer (mailto:christian@atombrenner.de) -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template match="/">
<xsl:apply-templates select="//msbuild" />
</xsl:template>
<xsl:template match="msbuild">
<table class="section-table" cellpadding="2" cellspacing="0" border="0" width="98%">
<tr><td class="sectionheader">
<b><xsl:value-of select="@solution_name"/></b> in <xsl:value-of select="@solution_dir"/>:
<xsl:choose>
<xsl:when test="@error_count > 0">
Build failed with <xsl:value-of select="@error_count"/> errors
</xsl:when>
<xsl:when test="@warning_count > 0">
<xsl:value-of select="@project_count"/> Projects built with <xsl:value-of select="@warning_count"/> warnings
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@project_count"/> Projects built with no warnings at all :-)
</xsl:otherwise>
</xsl:choose>
</td></tr>
<xsl:if test="@error_count = 0 and @warning_count = 0"> <tr><td><img src="/ccnet/your_happy_image.jpg" alt="Happy Image :-)" /> Juchuu !!!</td></tr></xsl:if>
<xsl:apply-templates select="project[error|warning]" />
</table>
</xsl:template>
<xsl:template match="project" >
<tr>
<td class="section-project">
<b><xsl:value-of select="@name"/></b> in <xsl:value-of select="@dir"/>:
</td>
</tr>
<tr>
<xsl:element name="td">
<xsl:attribute name="class">
<xsl:if test="../@error_count > 0">section-error</xsl:if>
<xsl:if test="../@error_count &lt;= 0">section-warning</xsl:if>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</tr>
</xsl:template>
<xsl:template match="error|warning">
<xsl:value-of select="@code" />: <xsl:value-of select="@message" /> in <xsl:value-of select="@name" /><xsl:value-of select="@pos"/><br/>
</xsl:template>
</xsl:stylesheet>
+8
View File
@@ -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;' {} \;