How to use Common.Logging.Log4Net.Universal instead of Common.Logging.Log4Net208 - log4net

I have a solution that I cannot update to Log4Net 2.0.12 because the Common.Logging.Log4Net208 has not been updated and the project seems pretty well dead.
While searching the nuget package, I saw Common.Logging.Log4Net.Universal
I added it (and removed the Common.Logging.Log4Net208) but there was a config section like-a-so:
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
...
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net208">
<arg key="configType" value="FILE-WATCH" />
<arg key="configFile" value="~/log4net.config" />
</factoryAdapter>
</logging>
</common>
I was not able to find any example as to how to set this up with Common.Logging.Log4Net.Universal as attempting with the same section produced an error while compiling as Log4NetLoggerFactoryAdapter was no longer found. And removing the complete section(s) caused error at runtime when logging.
Anyone has experience with Common.Logging.Log4Net.Universal?

Figured it out by going through examples:
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Universal.Log4NetFactoryAdapter, Common.Logging.Log4Net.Universal">
<arg key="configType" value="FILE-WATCH"/>
<arg key="configFile" value="~/log4net.config" />
</factoryAdapter>
</logging>
</common>

Related

NLog DB Configuration

From the docs https://github.com/NLog/NLog/wiki/Database-target
It seems settings are shown as attributes on the target element such as:
<target xsi:type="Database"
name="String"
dbUserName="Layout"
dbProvider="String"
and in the example below as separate child nodes:
<target name="database" xsi:type="Database">
<connectionStringName>NLogDb</connectionStringName>
Neither work for me, I just get Invalid configuration exceptions with this message:
NotSupportedException: Parameter connectionStringName not supported on DatabaseTarget
The Config File:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="info"
throwExceptions="true"
internalLogFile="c:\temp\internal-nlog.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="c:\temp\nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
<target xsi:type="Database"
name="database"
keepConnection="true"
useTransactions="true"
dbProvider="System.Data.SqlClient"
connectionStringName="DefaultConnection"
commandText="INSERT INTO Logs (EventDateTime, EventLevel, UserName, MachineName, EventMessage, ErrorSource, ErrorClass, ErrorMethod, ErrorMessage, InnerErrorMessage) VALUES (#EventDateTime, #EventLevel, #UserName, #MachineName, #EventMessage, #ErrorSource, #ErrorClass, #ErrorMethod, #ErrorMessage, #InnerErrorMessage)">
<parameter name="#EventDateTime" layout="${date:s}" />
<parameter name="#EventLevel" layout="${level}" />
<parameter name="#UserName" layout="${aspnet-user-identity}" />
<parameter name="#MachineName" layout="${machinename}" />
<parameter name="#EventMessage" layout="${message}" />
<parameter name="#ErrorSource" layout="${event-context:item=error-source}" />
<parameter name="#ErrorClass" layout="${event-context:item=error-class}" />
<parameter name="#ErrorMethod" layout="${event-context:item=error-method}" />
<parameter name="#ErrorMessage" layout="${event-context:item=error-message}" />
<parameter name="#InnerErrorMessage" layout="${event-context:item=inner-error-message}" />
</target>
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile,database" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxLevel="Info" final="true
" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
How it is being called in program.cs
var logger = NLog.Web.NLogBuilder.ConfigureNLog( "nlog.config" ).GetCurrentClassLogger();
(copied from their docs)
Must be missing something obvious, but since there is conflicting info in the docs, and copying other people's configs posted on here, not sure where to go with it
Looks like you are running on NetCore. NLog is not able to read connectionStringName from AppSettings.json as you have found out yourself (Requires extra dependencies to access IConfiguration).
One possible solution is using this extension:
https://www.nuget.org/packages/NLog.Appsettings.Standard/
And use connectionString (Instead of connectionStringName) in NLog.config:
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Appsettings.Standard"/>
</extensions>
<target xsi:type="Database" connectionString="${appsettings:name=ConnectionStrings.DefaultConnection}">
Alternative solution is to assign a GDC variable before logging:
NLog.GlobalDiagnosticsContext.Set("DefaultConnection", Configuration.GetConnectionString("DefaultConnection"));
And then use GDC in NLog.config:
<target xsi:type="Database" connectionString="${gdc:item=DefaultConnection}">
See also https://github.com/NLog/NLog/wiki/Gdc-layout-renderer
Update NLog.Extension.Logging ver. 1.4.0
With NLog.Extension.Logging ver. 1.4.0 then you can now use ${configsetting}
See also: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer

ImageMagick identify.exe returns nothing in parallel Apache Ant project

I use Apache Ant project to gather some information about textures. Here you can see a test project that does only reading without any further actions. This is a minimal set that reproduces one nasty bug. I have found that sometimes ImageMagick's identify.exe does not return anything – I've added a code that forces build to fail if so. If I run this project multiple times I will get unstable behavior. Sometimes project build successfully, sometimes it fails with several fail-messages. Developers of ImageMagick say that their tools are thread safe. But if identify.exe is not the case then what can be? I really need help of someone with advance knowledge about Apache Ant and ImageMagick.
<project default="default">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="image_magick_path" location="c:\Program Files\ImageMagick-6.8.9-Q8\"/>
<property name="images_path" location="path\to\folder\with\png\images"/>
<target name="default">
<for param="item" parallel="true">
<path>
<fileset dir="${images_path}">
<patternset id="pattern_images">
<include name="**\*.png"/>
<include name="**\*.jpg"/>
<include name="**\*.gif"/>
<include name="**\*.bmp"/>
</patternset>
</fileset>
</path>
<sequential>
<local name="image_width"/>
<tex_width file="#{item}" property="image_width"/>
<local name="image_height"/>
<tex_width file="#{item}" property="image_height"/>
<if>
<or>
<equals arg1="${image_width}" arg2=""/>
<equals arg1="${image_height}" arg2=""/>
</or>
<then>
<fail message="Got nothing. But why? Image: #{item}"/>
</then>
</if>
</sequential>
</for>
</target>
<macrodef name="tex_width">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%w"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="tex_height">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%h"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
</project>
Ok, I will write here how I managed to solve my problem. I hope it will help someone someday.
First thing I found is that PHP method 'getimagesize' is much faster so I decided to switch to it thus killing the main problem. I wrote following macrodef to get both image width and height:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="output"/>
<exec executable="php" outputproperty="output">
<arg value="-r"/>
<arg value=
""$size=getimagesize('#{file}');
echo($size[0].' '.$size[1]);""
/>
</exec>
<propertyregex
property="#{propertywidth}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>
Unfortunately this macrodef has abosutely same bug. Sometimes during parallel run some exec-tasks returned nothing in output. I was very upset so I decided to write another macrodef which I use now and finally it works fine. What I did was avoid reading anything from exec-task's 'stdout' and use tempfile-task instead. Here's final macrodef:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="file_dirname"/>
<dirname property="file_dirname" file="#{file}"/>
<local name="file_temp"/>
<tempfile property="file_temp" destdir="${file_dirname}" createfile="true"/>
<exec executable="php">
<arg value="-r"/>
<arg value=""$size=getimagesize('#{file}');
file_put_contents('${file_temp}', $size[0].' '.$size[1]);""/>
</exec>
<local name="file_temp_content"/>
<loadfile property="file_temp_content" srcfile="${file_temp}"/>
<delete file="${file_temp}"/>
<propertyregex
property="#{propertywidth}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>

NLog and Common.Logging nightmare

So I have tried everything I can find to get these two to play together.
I have installed the nuget package Common.Logging.NLog20,
My config looks like:
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog20" />
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I am using the nuget NLog.Configuration package so my nlog config is in a separate file called NLog.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogFile="nlog.ERRORS.txt" internalLogLevel="Error" >
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<!-- add your targets here -->
<target xsi:type="File" name="log" keepFileOpen="true"
fileName="${basedir}/log_${date:format=yyyyMMdd}.txt"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
<target name="log_errors_memory" xsi:type="Memory"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
<target name="log_all_memory" xsi:type="Memory"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="log" />
<logger name="*" minlevel="Trace" writeTo="log_all_memory" />
<logger name="*" minlevel="Error" writeTo="log_errors_memory" />
</rules>
</nlog>
I have tried changing the FactoryAdaptor to NLog, NLog2 and NLog20, I have tried changing the binding redirect, I have tried updating the Common.Logging to version 2.2.0.0. No matter what I do I get the exception:
{"Failed obtaining configuration for Common.Logging from configuration section 'common/logging'."}
Inner Exception:
{"An error occurred creating the configuration section handler for common/logging: Type Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e does not implement Common.Logging.ILoggerFactoryAdapter\r\nParameter name: factoryAdapterType\r\nActual value was Common.Logging.NLog.NLogLoggerFactoryAdapter. (D:\\Development\\Code\\DotNet\\vs2013\\exe\\CommandLine\\PSVImporter\\FidessaPSVImport.Test\\bin\\Debug\\FidessaPSVImport.Test.dll.config line 17)"}
What am I missing? This shouldn't be this hard to get working.
Okay, so after all the fixes above I had to also update the Common.Logging package to v2.2.0.0 and then update the binding redirects manually. This is really a sub-optimal deployment of the Common.Logging.NLog20 nuget package. You shouldn't have to do this.
Common.Logging.NLog20 - Version 2.2.0.0
Common.Logging - version 2.2.0.0
NLog - Version 2.1.0.0
Config looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogFile="nlog.ERRORS.txt" internalLogLevel="Error">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets>
<!-- add your targets here -->
<target xsi:type="File" name="log" keepFileOpen="true"
fileName="${basedir}/log_${date:format=yyyyMMdd}.txt"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
<target name="log_errors_memory" xsi:type="Memory"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
<target name="log_all_memory" xsi:type="Memory"
layout="${longdate} ${level:uppercase=true:padding=5} - ${logger:shortName=true} - ${message} ${exception:format=tostring}" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="log" />
<logger name="*" minlevel="Trace" writeTo="log_all_memory" />
<logger name="*" minlevel="Error" writeTo="log_errors_memory" />
</rules>
</nlog>
</value>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Here's an underhanded approach that will save you a lot of hassle. The adapter that ships with Common.Logging.NLogXX, NLogLoggerFactoryAdapter, does nothing special but setup up NLog for you. This is something that most people can do on their own.
In other words, if you've already setup NLog all you need to do is hookup Common.Logging to NLog. This can be done by writing a simple factory that will create NLog Loggers like this:
public class MyAdapter : AbstractCachingLoggerFactoryAdapter
{
protected override ILog CreateLogger(string name)
{
return (ILog)typeof(NLogLogger).GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(NLog.Logger) }, null)
.Invoke(new object[] { NLog.LogManager.GetLogger(name) });
}
}
public static void ConfigureLogging()
{
Common.Logging.LogManager.Adapter = new MyAdapter();
}
Latest NLog works without Common.Logging. In my case I just had to do following to avoid error "Failed obtaining configuration for Common.Logging from configuration section 'common/logging'"
Uninstall-Package Common.Logging
Uninstall-Package Common.Logging.Core
Install-Package NLog.Config
And then clear app.config from unnecessary configuration & use nlog.config instead. Like described here: http://nlog-project.org/download/
After that I had to refactor a bit code, but it works almost the same way as common.logging
LogManager.GetLogger(GetType().ToString()).Info("demo")

What is the right xdt:Locator parameter to transform this node?

I have the following in my app.config file. I am using Slow Cheetah and just want to replace replace configuration/entityFramework/defaultConnectionFactory/parameters/parameter so it points to a diff server. ie value-data source=some-server....
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="data source=.;Integrated Security=SSPI;Initial Catalog=SomeDb;MultipleActiveResultSets=true" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
I have tried to the following in the app.config.release but to no avail.
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="data source=dbserver;Integrated Security=SSPI;Initial Catalog=someDb;MultipleActiveResultSets=true"
xdt:Transform="Replace"
xdt:Locator="XPath(configuration/entityFramework/defaultConnectionFactory/parameters/parameter)" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
also tried xdt:Locator="Match(parameter)"
and xdt:Locator="XPath(parameter)
and many more but can't get it to work.
Ok. I feel a little silly but the solution is that I didn't need to specify a xdt:Locator.
If I just leave the App.Release.Config like this it will replace matching entry.
<parameter value="data source=dbserver;Integrated Security=SSPI;Initial Catalog=someDb;MultipleActiveResultSets=true"
xdt:Transform="Replace"/>
</parameters>

Not able to see the FxCop Report embeded in the Email using CruiseControl.Net

I have installed Cruise Control 1.5 on my machine and trying to configure the automated build. Everything is working fine. Application is building, i receive an email but I don't see the FXCop result embedded in the Build Email. What am i missing?
ccnet.config file
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="SampleProject">
<webURL>http://localhost/ccnet</webURL>
<workingDirectory>E:\\NewProject\\DevBuilds</workingDirectory>
<artifactDirectory>E:\\NewProject\\DevBuilds\Artifacts</artifactDirectory>
<modificationDelaySeconds>600</modificationDelaySeconds>
<category>Dev Build</category>
<sourcecontrol type="svn">
<trunkUrl>https://mycompany.com/svn/trunk/MyApplication</trunkUrl>
<workingDirectory>E:\\NewProject\\DevBuilds\SourceCode</workingDirectory>
<autoGetSource>false</autoGetSource>
<executable>C:\Program Files\Subversion\bin\svn.exe</executable>
<username>username</username>
<password>password</password>
</sourcecontrol>
<initialState>Started</initialState>
<startupMode>UseInitialState</startupMode>
<triggers>
<intervalTrigger seconds="3600" buildCondition="IfModificationExists" />
</triggers>
<state type="state" directory="E:\\NewProject\\DevBuilds" />
<labeller type="iterationlabeller">
<prefix>1.0</prefix>
<duration>1</duration>
<releaseStartDate>2012/04/11</releaseStartDate>
<separator>.</separator>
</labeller>
<tasks>
<nant>
<executable>E:\NewProject\Installables\nant\bin\nant.exe</executable>
<baseDirectory>E:\\NewProject\\Build Files</baseDirectory>
<buildFile>Build.xml</buildFile>
<targetList>
<target>Run</target>
</targetList>
<buildTimeoutSeconds>5000</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>E:\NewProject\DevBuilds\FxCopOutput\FxCop-results.xml</file>
</files>
</merge>
<xmllogger logDir="E:\\NewProject\\DevBuilds\Artifacts\\buildlogs" />
<email from="Checkins#symphonysv.com" mailhost="smtp.gmail.com" includeDetails="true" useSSL="false">
<users>
<user name="dev1" group="buildmaster" address="myname#gmail.com"/>
</users>
<groups>
<group name="buildmaster">
<notifications>
<notificationType>Always</notificationType>
</notifications>
</group>
</groups>
</email>
</publishers>
</project>
</cruisecontrol>
Build.xml
<?xml version="1.0"?>
<project name="Test" default="Run" basedir=".">
<property name="BuildNumber" value="1.0.0.0"/>
<property name="SourceControlURL" value="https://mycompany.com/svn/trunk/MyApplication/"/>
<property name="BuildFile" value=".\Build.xml"/>
<property name="TagBuild" value="false"/>
<property name="BuildType" value="Release"/>
<property name="BuildTargetDir" value="E:\NewProject\DevBuilds\Executables"/>
<property name="BuildWorkDir" value="E:\NewProject\DevBuilds\SourceCode"/>
<property name="MSBUILD" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319"/>
<property name="FxCopOutPutDirectory" value="E:\NewProject\DevBuilds\FxCopOutput" />
<property name="FxCopInputDirectory" value="E:\NewProject\DevBuilds" />
<target name="Run" description="Starting ThinkPets Build">
<call target="GetLatestCode"/>
<call target="BuildCode"/>
<call target="BuildASPWebSite"/>
<call target="runFxCop"/>
</target>
<target name="GetLatestCode">
<echo message="Updating Code From SVN to ${BuildWorkDir}"/>
<exec program="svn.exe">
<arg line="checkout ${SourceControlURL} ${BuildWorkDir} -q"/>
</exec>
</target>
<target name="BuildCode">
<echo message="Building VS10 Projects Web" />
<exec program="${MSBUILD}\msbuild.exe" failonerror="true">
<arg line=" "${BuildWorkDir}\Application.sln" /t:Rebuild /p:Configuration=Release /V:q"/>
</exec>
</target>
<target name="BuildASPWebSite">
<echo message="Building ASP Web Site" />
<exec program="${MSBUILD}\aspnet_compiler.exe" failonerror="true">
<arg line=" -v / -p "${BuildWorkDir}\MyDir" -f -c "${BuildTargetDir}" "/>
</exec>
</target>
<target name="runFxCop" depends="BuildCode">
<exec program="C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe" failonerror="false">
<arg line="/p:${FxCopInputDirectory}\SampleProject.FxCop /o:${FxCopOutPutDirectory}\FxCop-results.xml"/>
</exec>
</target>
</project>
There are a few points you missed:
You need to add <includeDetails>true</includeDetails> to your e-mail publisher block. This will give you HTML e-mails.
In order to transform your XML build results into HTML you need to add an <xslFiles> section to your e-mail publisher block. The elements of this block point to XSL transformation files in [CCNET_INSTALL_DIR]\server\xsl.
So for including the FxCop summary just as appears in CCNET webdasboard this is your e-mail publisher block:
<email from="Checkins#symphonysv.com" mailhost="smtp.gmail.com" includeDetails="true" useSSL="false">
<users>
<user name="dev1" group="buildmaster" address="myname#gmail.com"/>
</users>
<groups>
<group name="buildmaster">
<notifications>
<notificationType>Always</notificationType>
</notifications>
</group>
</groups>
<includeDetails>true</includeDetails>
<xslFiles>
<file>xsl\fxcop-summary_1_36.xsl</file>
</xslFiles>
</email>
Thanks Chairman for your valuable time. I think my mistake was that I did not host the "ccnet" application on my machine which resulted in not able to find the xsls for the publishers. When I used the same settings and config file on the Server machine with "ccnet" application hosted, I was able to see the FxCop summary in the email. Please correct my understanding if wrong.

Resources