How to get NLog working outside VS Development Environment - vb.net

I have a bit of a conundrum here. For some reason my Nlog implementation will no longer work from an installed executable, works perfectly well from the VS2013 development environment, but nada from the installed executable.
DevEnv is VB.NET.
My first port of call in terms of diagnostics was to add:
internalLogFile="c:\log.txt" internalLogLevel="Trace"
to the nlog.config file, but this suffers from the same problem, (works in devenv but not from executable). My log files get written to a folder structure in the CommomApplicationData folder,
d:\programdata\CompanyName\AppName\Logs
nlog.config is installed in and read from:
d:\programdata\CompanyName\AppName\QueryConfig
the reason for this is that our corporate IT security prohibits writes to the C: drive (other than via authorised installs), and I have a variable in the nlog.config file 'LogId', that needs to be updated from the app. Here is my nlog.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"
internalLogFile="c:\log.txt" internalLogLevel="Trace">
<variable name="companyName" value="Company Name"/>
<variable name="logFolder" value="${specialfolder:folder=CommonApplicationData}/${companyName}/AppName/Logs/"/>
<variable name="startDelim" value="["/>
<variable name="endDelim" value="]"/>
<variable name="filename" value="${date:format=yyyy-MM-dd}_${gdc:item=appName}.log"/>
<variable name="fieldDelim" value="|"/>
<variable name="logId" value="1"/>
<variable name="headerLayout" value="Application Name: ${processname} File Version: ${gdc:item=fileVersion} Released: ${gdc:item=releaseDate} User: ${windows-identity}" />
<variable name="normalLayout" value="${gdc:item=logId}${fieldDelim}${date:format=HH\:mm\:ss}${fieldDelim}${windows-identity}${fieldDelim}${level}${fieldDelim}${message}${exception:format=tostring}" />
<variable name="traceLayout" value="${gdc:item=logId}${fieldDelim}${date:format=HH\:mm\:ss}${fieldDelim}${windows-identity}${fieldDelim}${level}${fieldDelim}${message}${exception:format=tostring}"/>
<targets async="true">
<target name="fileHeader"
xsi:type="File"
fileName="${logFolder}${filename}"
layout="${headerLayout}"/>
<target name="normal"
xsi:type="File"
fileName="${logFolder}${filename}"
layout="${normalLayout}"/>
</targets>
<rules>
<logger name="HeaderLogger" minlevel="Info" writeTo="fileHeader" final="true"/>
<logger name="*" minlevel="Trace" writeTo="normal" />
</rules>
</nlog>
This Nlog implementation has worked fine for the last 5 years the only difference is the diversion of the nlog.config and log file destination to the CommonApplicationData folder. Testing of a windows service app that uses the same logging implementation works fine from the same machine, the only differences are that it runs as a service under the system account and does not require write access to the Nlog.config file, as a consequence of which nlog.config resides in the application folder on the C: drive. Hope somebody has some input into this because its driving me crazy...!
Edit: I should add, that I have full Admin rights on this machine under my corporate user ID, however normal users won't.
Kind Regards
Paul J.
EDITED 2018-08-14
OK, so... as suggested have altered the relevant code to launch internal logging programmatically to write to log.txt in c:\temp. Curiously, this appears to work to an extent. However content of the output is rather sparse when compared to internal log output when launched via the config file. As expected, the actual application logging remains inactive.
Sample log from log.txt when internal logging implemented programmatically:
2018-08-13 15:21:34.9302 Debug Targets for HeaderLogger by level:
2018-08-13 15:21:34.9302 Debug Trace =>
2018-08-13 15:21:34.9302 Debug Debug =>
2018-08-13 15:21:34.9302 Debug Info =>
2018-08-13 15:21:34.9412 Debug Warn =>
2018-08-13 15:21:34.9412 Debug Error =>
2018-08-13 15:21:34.9412 Debug Fatal =>
2018-08-13 15:21:37.0902 Debug Targets for HeaderLogger by level:
2018-08-13 15:21:37.0902 Debug Trace =>
2018-08-13 15:21:37.0902 Debug Debug =>
2018-08-13 15:21:37.0932 Debug Info =>
2018-08-13 15:21:37.0932 Debug Warn =>
2018-08-13 15:21:37.0932 Debug Error =>
2018-08-13 15:21:37.0932 Debug Fatal =>
2018-08-13 15:21:39.1012 Trace LogFactory.Flush(00:00:15)
...
finally when the app is closed down the log finishes with:
2018-08-13 15:35:56.9262 Info Shutting down logging...
2018-08-13 15:35:56.9262 Info Logger has been shut down.
Kind Regards
Paul.

Related

NLog not logging on all levels

ASPNET Core 2.0 with latest Nlog.
All config files load correctly.
My config file is simple, I just want it to log every thing.
<?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="Warn"
internalLogFile="C:\wwwLogs\nlog.log">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<targets>
<target xsi:type="File" name="allfile" fileName="C:\wwwLogs\${shortdate}.log"
maxArchiveFiles="90"
archiveNumbering="DateAndSequence"
archiveAboveSize="250000"
archiveFileName="archive/log.{#######}.log"
archiveEvery="Day"
concurrentWrites="true"
layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
</rules>
</nlog>
I can see it in the trace log for nlog it is setting all levels to the correct output.
2017-11-01 14:21:26.3017 Trace Opening C:\wwwLogs\2017-11-01.log with allowFileSharedWriting=False
2017-11-01 14:21:28.5859 Debug Targets for TimeSlotApprovalService by level:
2017-11-01 14:21:28.5859 Debug Trace => allfile
2017-11-01 14:21:28.5859 Debug Debug => allfile
2017-11-01 14:21:28.5859 Debug Info => allfile
2017-11-01 14:21:28.5859 Debug Warn => allfile
2017-11-01 14:21:28.5859 Debug Error => allfile
2017-11-01 14:21:28.5859 Debug Fatal => allfile
In my application when I call this
_logger.LogDebug(JsonConvert.SerializeObject(resultList, Formatting.Indented));
_logger.LogError(JsonConvert.SerializeObject(resultList, Formatting.Indented));
_logger.LogCritical(JsonConvert.SerializeObject(resultList, Formatting.Indented));
_logger.LogWarning(JsonConvert.SerializeObject(resultList, Formatting.Indented));
_logger.LogTrace(JsonConvert.SerializeObject(rankedTimeSlots, Formatting.Indented));
Then the log file only logs these
2017-11-01 14:44:48.2570|TimeSlotApprovalService|**ERROR**|[json...
2017-11-01 14:44:48.2570|TimeSlotApprovalService|**FATAL**|[json...
2017-11-01 14:44:48.2570|TimeSlotApprovalService|**WARN**|[json...
Where are the rest?? Trace and Debug?? Info?
ASP.NET Core and its logging system Microsoft.Extensions.Logging use a central configuration. This configuration applies regardless of the attached logging providers. So if you use NLog as a logging provider, you will still have to configure the logging infrastructure.
By default, the web host builder will automatically use the configuration within the appsettings.json to configure the logging verbosity. And in the default template, this is what the configuration looks like:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
So the default minimum log level to log is Warning. So even if you configure your NLog provider to log at any logging level, it won’t actually receive logging instructions lower than Warning from the logging system.
So you will have to adjust the configuration there to change it. Set it to Trace and it should log everything.
Note that you should still consider using the configuration there as the source of truth on what log levels should be logged. So just keep your NLog configuration to log whatever it gets, and then adjust your appsettings.json to match whatever you want to actually log, depending on the current enviroment (you can create files like appsettings.Development.json and appsettings.Production.json to create environment-specific configurations).
If you want to do it by code:
var services = new ServiceCollection();
services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace));

MFP CLI cannot build-deploy project initially created with MFP Studio

Problem Context:
We initially created a MFP hybrid project with the iOS environment using MFP Studio plugin for Eclipse. We have this project under source control (Git on DevOps). Some team members in our team are doing iOS development for this project and since they are not familiar with Eclipse, they are wanting to use the CLI instead. Other developers in the same team will continue to use Studio since they are writing Java code for the MFP adapters and want to leverage the capabilities Eclipse provides such as compilation, code auto-completion, etc.
Problem:
After pulling down the MFP project code from Git (fresh pull), if Studio is first used to “Build All Environments” and “Run on MobileFirst Platform”, we can then run the MFP app without any problems. We can then also switch to the CLI for building and deploying artifacts and the CLI commands work just fine.
Now, say that after pulling down the code from Git (fresh pull), instead of using Studio, we start using right away the CLI for building and deploying artifacts. Under such scenario, the CLI throws errors. It seems that the CLI is missing steps that Studio knows how to do. The errors we get when using the CLI right away for building and deploying (mfp bd) after a fresh pull from Git are the following:
$ mfp bd
All apps and adapters were successfully built.
Initializing MobileFirst Console.
BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:147: Compile failed; see the compiler error output for details.
Total time: 1 second
Error: Build process failed. Please check the stack above for details.
BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:380: Element <project> inside <configureApplicationServer>: File '/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/bin/HatchReadyApp.war' does not exist.
Total time: 1 second
Error: Build process failed. Please check the stack above for details.
objc[81801]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Starting server worklight.
Server worklight started with process ID 81800.
[wladm] Unexpected response from http://192.168.1.126:10080/worklightadmin/management-apis/1.0/runtimes/HatchReadyApp/adapters?locale=en_US:
[wladm] <?xml version="1.0" encoding="UTF-8"?>
[wladm] <deploy-adapter-result ok="false" productVersion="6.3.0.00-20150214-1702">
[wladm] <transaction id="168" type="UPLOAD_ADAPTER" status="FAILURE" timeCreated="2015-04-13T13:53:18.599Z" timeUpdated="2015-04-13T13:53:18.870Z" userName="admin" appServerId="Liberty">
[wladm] <project name="HatchReadyApp"/>
[wladm] <description filename="SBBAdapter.adapter" name="SBBAdapter" alreadyDeployed="false"/>
[wladm] <errors>
[wladm] <error mbeanName="com.worklight.common.server.jmx.api:qualifier=HatchReadyApp,type=ProjectManagement" date="2015-04-13T13:53:18.831Z" phase="PREPARE" code="FAILURE" exception="RuntimeException" details="Runtime synchronization failed. Cannot deploy adapter to runtime"/>
[wladm] </errors>
[wladm] <warnings/>
[wladm] </transaction>
[wladm] </deploy-adapter-result>
Error: The MobileFirst server that you have configured does not appear to be running. Start the server with 'mobilefirst start'.
More details:
If I start the MFP server first before doing a 'mfp bd', it also fails with a similar error:
$ mfp start
Initializing MobileFirst Console.
BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:147: Compile failed; see the compiler error output for details.
Total time: 1 second
Error: Build process failed. Please check the stack above for details.
BUILD FAILED
/Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml:380: Element <project> inside <configureApplicationServer>: File '/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/bin/HatchReadyApp.war' does not exist.
Total time: 1 second
Error: Build process failed. Please check the stack above for details.
objc[55444]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Starting server worklight.
Server worklight started with process ID 55443.
MFP info output:
$ mfp info
OS: darwin x64
Release: 14.1.0
System Memory: 89MB free out of 16384MB
Node: v0.10.30
MobileFirst CLI: 6.3.0.00.20150214-1708
Current directory: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp
Current project: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp
Adapter: getOffers (/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/adapters/SBBAdapter/SBBAdapter.xml)
Description: SBBAdapter
Type: http
Procedures: test, getUser, getAccounts, getTransactions, getGoals, getDashboardData, getFeasibility, submitAuthentication, getTradeoffSolution, getOffers
Application: Hatch (/Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp/apps/Hatch/application-descriptor.xml)
Description: Hatch
Type: hybrid application
Features:
Environments: iphone
Skins:
Server location: /Users/olivieri/.ibm/mobilefirst/6.3.0/server
Server binary: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/bin/server
MobileFirst instance: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/usr/servers/worklight
objc[85669]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
WebSphere Application Server 8.5.5.3 (1.0.6.cl50320140731-0257) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_51-b13 (en_US)
Environment variables:
TERM_PROGRAM: Apple_Terminal
ANDROID_HOME: /Users/olivieri/android-sdks
SHELL: /bin/bash
TERM: xterm-256color
TMPDIR: /var/folders/c9/gf_f0_sd60q1mm9kxwgvlxsr0000gn/T/
Apple_PubSub_Socket_Render: /private/tmp/com.apple.launchd.JKtd63AtGc/Render
TERM_PROGRAM_VERSION: 343.6
TERM_SESSION_ID: D5FA1866-C7B1-4AC0-A045-B8BD0AF18A5D
ANT_HOME: /Users/olivieri/Development/apache-ant-1.9.4
USER: olivieri
SSH_AUTH_SOCK: /private/tmp/com.apple.launchd.ECR6tzx7Xe/Listeners
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x0
PATH: /Users/olivieri/Development/apache-ant-1.9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/IBM/MobileFirst-CLI:/Users/olivieri/Development/gradle-1.12/bin:/Users/olivieri/android-sdks/tools:/Users/olivieri/android-sdks/platform-tools
PWD: /Users/olivieri/git/Ready.App.3.Hatch/HatchReadyApp
LANG: en_US.UTF-8
XPC_FLAGS: 0x0
XPC_SERVICE_NAME: 0
SHLVL: 2
HOME: /Users/olivieri
LOGNAME: olivieri
DISPLAY: /private/tmp/com.apple.launchd.8nfQqEAeMS/org.macosforge.xquartz:0
_: /Applications/IBM/MobileFirst-CLI/IBMnode/bin/node
WLP_USER_DIR: /Users/olivieri/.ibm/mobilefirst/6.3.0/server/wlp/usr
Thanks to the IBM folks who helped us resolve this problem. To fix this issue, we had to make two changes to the following file: /Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/lib/build.xml
We replaced the following two sections [in this file] as shown below:
1)
<!--
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
</path>
-->
<path id="server-classpath">
<fileset dir="${worklight.jars.dir}" includes="worklight-jee-library.jar" />
<fileset dir="${worklight.server.install.dir}/wlp/dev" includes="**/*.jar" />
<!-- add server/lib folder to classpath -->
<fileset dir="${worklight.app.dir}/../server/lib" includes="**/*.jar" />
</path>
2)
<!--
<target name="build-WAR" description="Build worklight WAR for project">
<echo message="Building worklight WAR for project ${ProjectName}" />
<javac
srcdir="server/java"
destdir="bin/classes"
classpathref="server-classpath"
verbose="true"
includeantruntime="false"
/>
<war-builder
projectfolder="${basedir}"
destinationfolder="bin/war"
warfile="bin/${ProjectName}.war"
classesfolder="bin/classes">
</war-builder>
</target>
-->
<target name="build-WAR" description="Build worklight WAR for project">
<echo message="Building worklight WAR for project ${ProjectName}" />
<!-- first clear out the existing bin/classes contents -->
<delete includeemptydirs="true">
<fileset dir="bin/classes" includes="**/*"/>
</delete>
<javac
srcdir="server/java"
destdir="bin/classes"
classpathref="server-classpath"
verbose="true"
includeantruntime="false"
/>
<if>
<available file="server/java/resources" />
<then>
<!-- now copy the contents of server/java/resources into bin/classes so they get included in the war -->
<copy todir="bin/classes/resources" failonerror="false">
<fileset dir="server/java/resources"/>
</copy>
</then>
</if>
<war-builder
projectfolder="${basedir}"
destinationfolder="bin/war"
warfile="bin/${ProjectName}.war"
classesfolder="bin/classes">
</war-builder>
</target>
After making the above changes, we could then run the 'mfp restart' and 'mfp bd' commands without any errors.

CruiseControl.NET 1.8.5 - Not creating msbuild-results xml file

I'm pretty new to build servers but have been asked by my employer to do some testing (because F5 is not a build process, as the excellent article by Jeff Atwood says). At this stage, I'm working on getting some sample builds and test reports up and running on a CruiseControl.NET server. So far, I've gotten a build up and running (the configuration file will need some tidying up before adding new builds/projects but the proof of concept is there) but the reporting is causing something of a headache.
The main report I'm looking for is for out NUnit tests and SpecFlow integration tests. The tests run fine (as I'm getting a sensible looking xml file generated) and am looking to merge that in to the main build results so that I can show the results of the NUnit/SpecFlowtests.
Whenever the build completes, the following is reported in the messages (in ViewFarmReport.aspx): "Failing Tasks : XmlLogPublisher "
This combined with the following error reported in the Windows application log (source - CC.Net)
2015-03-24 08:36:52,987 [Initech.SuperCrm-DEV] ERROR CruiseControl.NET [(null)] - Publisher threw exception: ThoughtWorks.CruiseControl.Core.CruiseControlException: Unable to read the contents of the file: C:\CCNet\BuildArtifacts\Initech.SuperCrm-DEV\msbuild-results-7c657954-2c3e-405f-b0f1-7da1299788fd.xml ---> System.IO.FileNotFoundException: Could not find file 'C:\CCNet\BuildArtifacts\Initech.SuperCrm-DEV\msbuild-results-7c657954-2c3e-405f-b0f1-7da1299788fd.xml'.
(company/application name "censored")
This leads me to suspect that the failure to merge in the msbuild results (which I believe CruiseControl.NET automatically scrapes since version... 1.5 or 1.6?) is preventing the NUnit results from being merged in.
There is no msbuild-results file in the BuildArtifacts folder, which does not surprise me as I do not believe my current msbuild configuration allows for xml based logging as I am using the ThoughtWorks.CruiseControl.MsBuild.dll logger.
According to the online documentation for CruiseControl.NET there is XML enabled custom logger: ThoughtWorks.CruiseControl.MsBuild.XmlLogger which can be used, however the download location for this logger: here
appears not to exist any more.
Can anyone say whether I'm thinking along the right lines here and what my options are?
For reference, here is my complete configuration:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<cb:define MSBuildPath="C:\Windows\Microsoft.NET\Framework\v4.0.30319" />
<cb:define WorkingBaseDir="C:\CCNet\Builds" />
<cb:define ArtifactBaseDir="C:\CCNet\BuildArtifacts" />
<cb:define MSBuildLogger="C:\Program Files (x86)\CruiseControl.NET\server
\ThoughtWorks.CruiseControl.MsBuild.dll" />
<cb:define NUnitExe="C:\Jenkins\Nunit\nunit-console.exe" />
<cb:define name="vsts_ci">
<executable>C:\Jenkins\tf.exe</executable>
<server>http://tfs-srv:8080/tfs/LEEDS/</server>
<domain>CONTOSO</domain>
<autoGetSource>true</autoGetSource>
<cleanCopy>true</cleanCopy>
<force>true</force>
<deleteWorkspace>true</deleteWorkspace>
</cb:define>
<project name="Initech.Libraries" description="Shared libraries used in all Initech projects"
queue="Q1">
<state type="state" directory="C:\CCNet\State"/>
<artifactDirectory>$(ArtifactBaseDir)\Initech.Libraries</artifactDirectory>
<workingDirectory>$(WorkingBaseDir)\Initech.Libraries</workingDirectory>
<triggers>
<intervalTrigger
name="continuous"
seconds="30"
buildCondition="IfModificationExists"
initialSeconds="5"/>
</triggers>
<sourcecontrol type="vsts">
<cb:vsts_ci/>
<workspace>CCNET_Initech.Libraries</workspace>
<project>$/InitechLibraries/Initech.Libraries</project>
</sourcecontrol>
</project>
<project name="Initech.SuperCrm-DEV" description="Initech.SuperCrm Application, Development
Version" queue="Q1">
<cb:define ArtifactDirectory="$(ArtifactBaseDir)\Initech.SuperCrm-DEV" />
<cb:define WorkingDirectory="$(WorkingBaseDir)\Initech.SuperCrm-DEV" />
<cb:define OutputDirectory="$(WorkingDirectory)\Initech.SuperCrm\bin\Debug" />
<cb:define ProjectFile="Initech.SuperCrm.sln" />
<cb:define NUnitLog="$(WorkingDirectory)\NunitResults.xml" />
<state type="state" directory="C:\CCNet\State"/>
<artifactDirectory>$(ArtifactDirectory)</artifactDirectory>
<workingDirectory>$(WorkingDirectory)</workingDirectory>
<triggers>
<!-- check the source control every X time for changes,
and run the tasks if changes are found -->
<intervalTrigger
name="continuous"
seconds="30"
buildCondition="IfModificationExists"
initialSeconds="5"/>
</triggers>
<sourcecontrol type="vsts">
<cb:vsts_ci/>
<workspace>CCNET_Initech.SuperCrm-DEV</workspace>
<project>$/InitechSuperCrm/SuperCrm/Initech.SuperCrm-DEV</project>
</sourcecontrol>
<tasks>
<exec>
<executable>C:\Program Files (x86)\DXperience 12.1\Tools\DXperience
\ProjectConverter-console.exe</executable>
<buildArgs>$(WorkingDirectory)</buildArgs>
</exec>
<msbuild>
<executable>$(MSBuildPath)\MSBuild.exe</executable>
<workingDirectory>$(WorkingDirectory)</workingDirectory>
<projectFile>$(ProjectFile)</projectFile>
<timeout>900</timeout>
<logger>$(MSBuildLogger)</logger>
</msbuild>
<exec>
<executable>$(NUnitExe)</executable>
<buildArgs>/xml=$(NUnitLog) /nologo $(WorkingDirectory)\$(ProjectFile)
</buildArgs>
</exec>
</tasks>
<publishers>
<buildpublisher>
<sourceDir>$(OutputDirectory)</sourceDir>
<useLabelSubDirectory>true</useLabelSubDirectory>
<alwaysPublish>false</alwaysPublish>
<cleanPublishDirPriorToCopy>true</cleanPublishDirPriorToCopy>
</buildpublisher>
<merge>
<files>
<file>$(NUnitLog)</file>
</files>
</merge>
<xmllogger logDir="C:\CCNet\BuildArtifacts\Initech.SuperCrm-DEV\buildlogs" />
<artifactcleanup cleanUpMethod="KeepLastXBuilds"
cleanUpValue="50" />
</publishers>
</project>
</cruisecontrol>
I've been tearing my hair while trying to figure this out, and I don't have much to begin with, so any help would be greatly appreciated.
After a prolonged period of banging my head against the wall, I seem to have finally found the solution (well solutions).
1) Kobush.Build.dll (https://www.nuget.org/packages/Kobush.Build/) can be used as the logger for MSBuild. Looking at the attributions in CruiseControl.NET's documentation, it appears to have been written by the same developer (but extended).
2) Some tweaks were needed due to the default location of the msbuild-report output. Because, by default, it was dumped to the buildartifacts folder then it is susceptible to being prematurely deleted.
I no longer clean the publish directory prior to copying (in the buildpublisher) and perform the merge and xmllogger portions of the publisher before artifact cleanup.
As a result, I now have msbuild and nunit output/results integrated in to the main build log and these can be consumed through the CruiseControl.NET dashboard.
There's probably a tidier way of handling this, but at the moment I'm just getting a proof of concept going.

CruiseControl.Net Web Dashboard not displaying results

Having problems displaying the results in CruiseControl.net web dashboard.
I've built a config file which kicks off a build of the project. It then runs nunit over my tests, they execute and finish just fine (I can open the log and see the results there). The ccnet logs show that the log files were successfully merged. However, try as I might, I can't get it to appear in the web dashboard. It just gives the frustrating:
BUILD FAILED
Project: GroundControlTests
Date of build: 2011-01-07 17:16:36
Running time: 00:00:58
Integration Request: mmayo triggered a build (ForceBuild) from PC0098
Projects built with no warnings at all :-)
Modifications since last build (0)
message, despite failing.
I suspect it has something to do with the xsl transforms, but have tried just about everything I can think of.
Certainly if I click View Build log, it shows, but the main report doesn't show passes and fails :(
My config files are below, any suggestions appreciated!
---nant.build---
<project name="GroundControl" default="cleanNunit" basedir=".">
<description>Cleanup tasks</description>
<target name="cleanNunit"
description="removes nunit log file">
<delete file="${CCNetArtifactDirectory}\nunit-results.xml"
failonerror="true" />
</target>
</project>
-----ccnet.config-------
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="GroundControlTests">
<workingDirectory>C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot</workingDirectory>
<artifactDirectory>C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot</artifactDirectory>
<prebuild>
<nant>
<executable>C:\Nant\bin\nant.exe
</executable>
<baseDirectory>C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot</baseDirectory>
<nologo>false</nologo>
<buildFile>nant.build</buildFile>
<targetList>
<target>cleanNunit</target>
</targetList>
</nant>
</prebuild>
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
</executable>
<workingDirectory>C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot
</workingDirectory>
<projectFile>GroundControlReboot.sln</projectFile >
<buildArgs>/noconsolelogger
/v:quiet
/noconlog
/p:Configuration=Debug
/p:ReferencePath="C:\Program Files\NUnit 2.5.9\bin;C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
/p:AdditionalReferencePath="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
</buildArgs>
<targets>ReBuild</targets >
<timeout>180</timeout >
<!-- <logger>C:\Program Files\CruiseControl.NET\server\Rodemeyer.MsBuildToCCNet.dll</logger>-->
</msbuild>
<exec>
<executable>C:\Program Files\NUnit 2.5.9\bin\net-2.0\nunit-console.exe
</executable >
<buildArgs>/xml:C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot\nunit-results.xml
C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot\GroundControlReboot\bin\Debug\GroundControlReboot.dll
</buildArgs>
<buildTimeoutSeconds>180</buildTimeoutSeconds>
</exec>
</tasks>
<publishers>
<merge>
<files>
<file>
C:\Source\Wholesale\Code.EventControl.TestingFramework\GroundControlReboot\*-results.xml
</file>
</files>
</merge>
<xmllogger />
<statistics />
<artifactcleanup cleanUpMethod="KeepLastXBuilds"
cleanUpValue="20" />
</publishers>
</project>
</cruisecontrol>
-----dashboard.config-------
<?xml version="1.0" encoding="utf-8"?>
<dashboard>
<remoteServices>
<servers>
<server name="local" url="tcp://localhost:21234/CruiseManager.rem" allowForceBuild="true" allowStartStopBuild="true" backwardsCompatible="false" />
</servers>
</remoteServices>
<plugins>
<farmPlugins>
<farmReportFarmPlugin />
<cctrayDownloadPlugin />
<administrationPlugin password="" />
</farmPlugins>
<serverPlugins>
<serverReportServerPlugin />
</serverPlugins>
<projectPlugins>
<projectReportProjectPlugin />
<viewProjectStatusPlugin />
<latestBuildReportProjectPlugin />
<viewAllBuildsProjectPlugin />
</projectPlugins>
<buildPlugins>
<buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\header.xsl</xslFile>
<xslFile>xsl\msbuild2ccnet.xsl</xslFile>
<xslFile>xsl\modifications.xsl</xslFile>
<xslFile>xsl\nant.xsl</xslFile>
<xslFile>xsl\tests.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<buildLogBuildPlugin />
</buildPlugins>
<securityPlugins>
<simpleSecurity />
</securityPlugins>
</plugins>
</dashboard>
When I deployed the nunit package from the dashboard admin it generated three things:
Under buildReportBuildPlugin it added xsl\unittests.xsl. This is for the build summary page.
It also generated two items for the sidebar to see nunit details (xsl\tests.xsl) and nunit timings (xsl\timings.xsl). It looks like you have the nunit details xsl file defined for the build summary page which may be why you don't see anything. If you use xsl\unittests.xsl instead (and reload the dashboard so it actually reads the updated file) that may work. Another option is to just deploy the nunit package from the web dashboard administration page which will update the dashboard.config file for you.
<buildPlugins>
<buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\header.xsl</xslFile>
<xslFile>xsl\modifications.xsl</xslFile>
<xslFile>xsl\unittests.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<buildLogBuildPlugin />
<xslReportBuildPlugin description="NAnt Output" actionName="NAntOutputBuildReport" xslFileName="xsl\NAnt.xsl"></xslReportBuildPlugin>
<xslReportBuildPlugin description="NAnt Timings" actionName="NAntTimingsBuildReport" xslFileName="xsl\NAntTiming.xsl"></xslReportBuildPlugin>
<xslReportBuildPlugin description="NUnit Details" actionName="NUnitDetailsBuildReport" xslFileName="xsl\tests.xsl"></xslReportBuildPlugin>
<xslReportBuildPlugin description="NUnit Timings" actionName="NUnitTimingsBuildReport" xslFileName="xsl\timing.xsl"></xslReportBuildPlugin>
</buildPlugins>

CruiseControl.Net error: Unknown plugin for <msbuild>

I'm trying to get CruiseControl.Net working with MSBuild (this is my first exposure to CruiseControl.Net). I thought I'd done the configuration correctly, however I just get the following error message when starting up:
[cc]Jun-22 20:02:55 Main - error setting config file on controller
net.sourceforge.cruisecontrol.CruiseControlException: error configuring project MyProject
at *SNIP*
Caused by: net.sourceforge.cruisecontrol.CruiseControlException: Unknown plugin for: <msbuild>
at *SNIP*
[cc]Jun-22 20:02:55 Main - error configuring project MyProject
As far as I can work out, this would appear to indicate that I'm missing the MSBuild plugin, however all documentation that I can find indicates that the MSBuild plugin has been included with CruiseControl.Net since version 1.0
I'm using the latest binary release (v 2.8.3)
Here is my config xml:
<project name="MyProject">
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers></bootstrappers>
<modificationset quietperiod="10">
<filesystem folder="C:\snip\main"/>
</modificationset>
<schedule interval="60">
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\snip\main</workingDirectory>
<projectFile>MyProject.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
<targets>Build;Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</schedule>
<log />
<publishers />
</project>
Any advice on how I can troubleshoot this would be much appreciated.
Aggg - it appears that I have unwittingly downloaded CruiseControl, instead of CruiseControl.Net (and to make things even more confusing I was looking at CruiseControl.Net documentation)