PartCover generates empty output file - nant

I'm currently trying to create a Nant task for our TeamCity setup so that our UnitTests are ran through Gallio and covered by PartCover. The task looks like this:
<!-- UnitTest Configuration -->
<!-- ====================== -->
<!-- This configuration runs the tests through Gallio with MbUnit together with
PartCover to get the results of the test together with the coverage results
-->
<target name="unitTest">
<echo message="Unittesting ${AssemblyToTest}"/>
<exec program="${Paths.Tools}\PartCover\Partcover.exe" failonerror="true">
<arg line="--target "${Paths.Tools}\Gallio\Gallio.Echo.exe"" />
<arg line="--target-work-dir ${AssemblyToTestLocation}"/>
<arg line="--target-args /r:Local "${AssemblyToTest}"" />
<arg line="--include "[${Tests.TestedAssemblyName}]*"" />
<arg line="--output ${Paths.Output}\Coverage.xml" />
</exec>
</target>
The tests are running, we can see this in TeamCity, and a Coverage.xml file is generated, but empty. There's only a single line in it.
Output of the variables:-
${Paths.Tools} : C:\Robinson\Trunk\
${Tests.TestedAssemblyName} : Name of the DLL
${AssemblyToTestLocation} : Path to the DLL
Am I missing something?
EDIT
The TeamCity application is running on a Windows Server 2003 R2 Server, and all the build-agents performing the work are currently running on Windows XP Systems, all 32bit installations.

I believe we covered this issue in https://github.com/sawilde/partcover.net4/issues/46
and the solution was along the lines of
--include [${Tests.TestedAssemblyName}*]* ?

Related

Ant script to execute Soap UI Mock and Soap UI Test suite

I want to integrate soup ui project to jenkins. I have a test suite and a mock service , The mock service should be running in order to test the test suite.
I wrote a build script to execute the mock service first and then the test case. The following is the script
<project name="test" default="DIAG_COMPLETE" basedir=".">
<property name="project" value="./Complete--soapui-project.xml" />
<target name="DIAG_COMPLETE" depends="DIAG" >
<exec executable="D:\Soapui\soapUI-4.5.2\bin\testrunner.bat" failonerror="false" failifexecutionfails="false" >
<arg line="-sdiag_upload_tc -rja -f./reports ${project}"/>
</exec>
</target>
<!-- invokes the mock service -->
<target name="DIAG" >
<exec executable="D:\Soapui\soapUI-4.5.2\bin\mockservicerunner.bat" failonerror="false" failifexecutionfails="false" >
<arg line="-m'DBDiagnosticDataTransmissionSOAPBinding MockService' -p8088 -a/mockDBDiagnosticDataTransmissionSOAPBinding -b ${project}"/>
</exec>
</target>
</project>
I am not sure if this is the write approach.
Only if this works fine, I can integrate it with jenkins.
and this does not work because the mock service is not getting started.
I want an approach to proceed further in my jenkins integration.
Thanks Jacob Marshell

Ant script stops executing targets after the target build-war-deploy of a gwt project

I have an ant script which does in the beginning some checks and then compiles the code and deploys it to the tomcat server. The script for the build-war-deploy process looks like this:
<target name="build-war-deploy" depends="clean-up,gwtc,check-settings" description="Package GWT app to web archive and deploy to web server">
<war basedir="${war.dir}" destfile="${deploy.dir}/${app.name}.war" webxml="${webinf.dir}/web.xml">
<!-- <include name="WEB-INF/**" /> -->
<webinf dir="${webinf.dir}/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
This target works perfectly fine, meaning after running the ant script the application is indeed deployed on tomcat.
After the build-war-deploy target I need to do some cleanup processes and therefore I created some other targets and added an dependency to the build-war-deploy target so that it is being executed afterwards.
<target name="cleanup" depends="build-war-deploy" description="clean up processes">
<exec dir="./" executable="python" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
</target>
However, after the ant script executes the build-war-deploy target it stops and says that the build was successful. Does anyone know why it did not perform the last target?
build-war-deploy:
[war] Building war: C:\Apache Tomcat\apache-tomcat-6.0.33\webapps\test.war
BUILD SUCCESSFUL
Total time: 2 minutes 22 seconds
I would try using an outputproperty. Perhaps the python file is executing -- not doing what you want but executing and returning the results which you never see. I mean if the python script returns an error message, doesn't ant view that as successfully executing?
Something like:
<exec dir="./" executable="python" outputproperty="outProp" failonerror="true">
<arg line="deploy_cleanup.py ${app.name}" />
</exec>
<echo>${outProp}</echo>
outputproperty: The name of a property in which the output of the command should be stored. Unless the error stream is redirected to a separate file or stream, this property will include the error output.

NAnt + Project with GUID must be included

I just started using NAnt today, I followed some of the examples. I am having a hard time with one issue:
Its saying: "Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work."
Now I was able to track down the project. Here is my directory structure:
c:\dev\stockclockbuild -> this is where the solution and build file is located.
So I run the command:
nant -buildfile:c:\dev\stockclockbuild\stocks.build
I have a project that it located in c:\dev\_sharedlibs\mdrlibs called "MDR.StockPlatform" which seems to get included, but within that project file I found the project (dependency) that has the GUID mentioned in the error.
That project is called "MDR.Base" but its located in the same folder as MDR.StockPlatform.
Also if I were to open this solution and build it in visual studio it builds without errors.
Here is the complete verbose output:
c:\Dev\_Misc\Tools\nAnt\bin>nant -buildfile:c:\dev\stockclockbuild\stocks.build
NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///c:/dev/stockclockbuild/stocks.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: rebuild
clean:
build:
build.stockclock:
[solution] Starting solution build.
[solution] Loading projects...
[solution] Loading project 'c:\dev\stockclockbuild\StockClock.Common\StockClock
.Common.csproj'.
[solution] Using MSBuild version 4.0.30319.1.
[solution] Loading referenced project 'c:\dev\_SharedLibs\MDRLibs\MDR.StockPlat
form\MDR.StockPlatform.csproj'.
BUILD FAILED
Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work.
Total time: 0.6 seconds.
Here is a copy of the build file:
<project name="Solution Build Example" default="rebuild">
<property name="configuration" value="release"/>
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="build" description="Build all targets.">
<call target="build.stockclock"/>
</target>
<target name="rebuild" depends="clean, build" />
<target name="build.stockclock">
<solution configuration="${configuration}" solutionfile="Stockclock.sln" verbose="true">
</solution>
</target>
</project>
I'm assuming you're using a modern IDE, and from the NAnt Documentation:
Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and
projects are supported. Support for .NET Compact Framework projects is also not
available at this time.
In my NAnt scripts I use the NauckIT MSBuild task:
<msbuild projectFile="${solution.file}" targets="Build" verbosity="Quiet">
<property name="Configuration" value="${build.configuration}" />
<property name="Platform" value="${build.platform}" />
<arg value="/flp:NoSummary;Verbosity=normal;LogFile=${build.log}" />
<arg value="/p:SignAssembly=true" if="${isReleaseBuild}" />
<arg value="/p:AssemblyOriginatorKeyFile=${solution.keyfile}" if="${isReleaseBuild}" />
<arg value="/p:DelaySign=false" if="${isReleaseBuild}" />
</msbuild>
However that is a personal preference as you could also use the NAnt exec task and call msbuild directly.

How to rebuild solution using NAnt?

I am using following command in NAnt build file
<msbuild project="${appsdest}\${targetname}\${targetname}.sln"/>
appsdest and targetname are variable contain application project path and targetname is the variable contain project name to be rebuild.
but when using this command it build the solution but the time stamp of dlls are not updated.
I need to rebuild the solution and the latest dlls need to be place in debug folder.
can anyone tell me how to rebuild the solution using the msbuild command as written above?
Thanks
I don't use the MSBUILD tasks in NAnt, I just call the msbuild executable directly and it has worked well for me.
<target name="build">
<exec program="${MSBuildPath}">
<arg line='"${SolutionFile}"' />
<arg line="/property:Configuration=${SolutionConfiguration}" />
<arg value="/target:Rebuild" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
<arg line='/logger:"C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll"'/>
</exec>
</target>
I write more about it here: http://enterpriseyness.com/2009/12/continuous-integration-with-cruise-control-net-nant
You need to use the 'Rebuild' target:
<msbuild project="${appsdest}\${targetname}\${targetname}.sln" target="Rebuild"/>

How can I execute a Perl script using the Ant exec task?

I currently have this in my Ant build script:
<exec dir="${basedir}" executable="perl">
<arg line="${basedir}/version.pl -major"/>
</exec>
However, when that runs, I get this error message:
[exec] Could not open -major
[exec] Result: 2
To me, that says that what I have is trying to run a file called -major, which doesn't exist. The file is version.pl which takes an argument of -major.
How can I alter this to run version.pl with the argument -major?
Note that I am running the ant script on a Solaris machine, however cross-platform or solutions for other OSes are welcome for posterity.
I made a quick little Perl script that didn't do a whole lot and ran it just fine passing command line arguments to it using Ant 1.5 on a Solaris box.
<project name="perly" basedir="." default="run">
<target name="run">
<exec executable="perl" dir="${basedir}">
<arg value="version.pl"/>
<arg value="-major"/>
</exec>
</target>
</project>
$ ant run
What I can't quite understand is how you are getting "Could not open -major". Is this a custom die message or something? Is there supposed to be a filename passed instead of major?
You can try this:
<exec executable="perl" dir="${basedir}">
<arg value="version.pl"/>
<arg value="-major"/>
</exec>
On windows that is
Try this if it works:
<exec dir="${basedir}" executable="./test.pl">
<arg line="-major"/>
</exec>
From the ant exec doc:
dir: the directory in which the command should be executed.
So i guess it does a cd to the $dir and exec the $executable (shebang set)