Unable to Run test case through Nant when using log4net - build

I am working on a dotnet 2008, Nunit 2.6,Nant0.91 application.
I am using log4net for my logging purposes.
When trying to run test cases through Nunit, a log file is generated, but when I try to run it through Nant, I am unable to run my test case.
I am pasting the complete information present in my build file:
<?xml version="1.0" encoding="utf-8"?>
<project name="w2" default="run" basedir=".">
<!--Here we are building DLL -->
<target name="build">
<mkdir dir="Libraries" />
<mkdir dir="Output"/>
<csc target="library" output="Libraries/${project::get-
name()}.dll">
<sources>
<include name="C:\\Users\\rm99699\\Documents\\Visual Studio
2008\\Projects\\w2\\w2\\*.cs" />
<include name="C:\\Users\\rm99699\\Documents\\Visual Studio 2008\
\Projects\\w2\\w2\\app.config.xml"/>
</sources>
<references basedir="Libraries">
<include name="${nant::scan-probing-
paths('nunit.framework.dll')}" />
<include name="${nant::scan-probing-paths('log4net.dll')}" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.Support.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\ThoughtWorks.Selenium.Core.dll" />
</references>
</csc>
</target>
<!--Here we are running testcases -->
<target name="run" depends="build">
<nunit2 failonerror="false" >
<formatter type="Xml" usefile="true" extension=".xml"
outputdir="Output"/>
<test assemblyname="C:\\Users\\rm99699\\Documents\\Visual Studio 2008\
\Projects\\w2\\w2\\Libraries\\w2.dll" appconfig="C:\\Users\\rm99699\
\Documents\\Visual Studio 2008\\Projects\\w2\\w2\\app.config">
<references basedir="Libraries">
<include name="${nant::scan-probing-
paths('nunit.framework.dll')}" />
<include name="D:\selenium-dotnet-2.8.0\net35\WebDriver.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.Support.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\ThoughtWorks.Selenium.Core.dll" />
<include name ="D:\nant-0.91-bin\nant-0.91\bin\lib\common
\2.0\log4net.dll" />
<!-- <include name="${nant::scan-probing-paths('log4net.dll')}" />-->
</references>
</test>
</nunit2>
</target>
</project>
Based on my build file, are there any visible errors that are preventing me from running my test case?

What is the console output? NAnt includes log4net in it's core, and I've seen cases where it causes problems when one's code uses a different version of log4net than NAnt does. You could try using an <exec> task to run the unit tests -- especially since NAnt's <nunit2> task uses a heinously outdated NUnit 2.2.

Related

TruePlay interface

I tried to run TruePlay tutorial from https://msdn.microsoft.com/en-us/library/windows/desktop/mt808781(v=vs.85).aspx , but got an error :
"Unable to activate Windows Store app 'AppName'. The ProcessName
process started, but the activation request failed with error
'ErrorNumber'(it says "an error has been found in the system binary file, try to restore your PC)- translation from russian "
I used a new C++ UWP project in Visual Studio 2017
Also, when i change my Package.appxmanifest (like in tutorial from link above) and build the project this warning comes out:
https://i.stack.imgur.com/2gflN.png
File manifest:
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
<Identity
Name="76f3b46c-58e3-422b-a2ee-c9d7dfd62e9b"
Publisher="CN=dana"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="76f3b46c-58e3-422b-a2ee-c9d7dfd62e9b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>App6</DisplayName>
<PublisherDisplayName>dana</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="App6.App">
<uap:VisualElements
DisplayName="App6"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="App6"
BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="gameMonitor" />
<rescap:Capability Name="protectedApp" />
</Capabilities>
</Package>

MSBuild: Do I need Target Rebuild?

I use a build file to build and test my project.
I have a Compile-Target which has this line "Targets = "Rebuild". Do I really need this line? Using Visual Studio I know that I can clean a Solution and build it again, or I can just rebuild the solution.
In my msbuild-file I delete my main folder BuildArtifacts before creating him again. I used this Tutorial and I don't know why he uses Target=Rebuild?
This is my build file:
<Project ToolsVersion="4.0" DefaultTargets="RunUnitTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Falls Eigenschaften nicht gesetzt -> Release & Any CPU als default-->
<PropertyGroup>
<!-- ... -->
</PropertyGroup>
<ItemGroup>
<!-- ... -->
</ItemGroup>
<!-- All the stuff go into my main folder -->
<Target Name="Init" DependsOnTargets="Clean">
<MakeDir Directories="#(BuildArtifacts)" />
</Target>
<!-- delete my main folder -->
<Target Name="Clean">
<RemoveDir Directories="#(BuildArtifactsDir)" />
</Target>
<!-- delete NUnit-Files -->
<Target Name="CleanAfter">
<RemoveDir Directories="#(NunitDir)" />
</Target>
<Target Name="Compile" DependsOnTargets="Init">
<MSBuild Projects="#(SolutionFile)"
Targets="Rebuild"
Properties="OutDir=%(BuildArtifactsDir.FullPath);
Configuration=$(Configuration);
Platform=$(BuildPlatform)" />
</Target>
<Target Name="RunUnitTests" DependsOnTargets="Compile">
<Exec Command='"#(NUnitConsole)" "#(UnitTestsDLL)" --result=console-test.xml --work=BuildArtifacts' />
<CallTarget Targets="CleanAfter" />
</Target>
</Project>
This depends on your own needs: do you need the whole solution to be rebuilt or not? Arguably, on a build server, you want to do a complete clean/rebuild after every commit to make sure the codebase is sane. Removing just the output directory (I assume that is what the Clean starget does) doesn't necessarily remove all object files as well since they typically go into the intermediate directory which might not be the same as the output directory.

axis-java2wsdl task classpath setting problem

here is my build.xml
<?xml version="1.0" standalone="yes"?>
<path id='axis2.classpath'>
<fileset dir='D:\Tools\axis2-1.5.1-bin\axis2-1.5.1\lib'>
<include name='**/*.jar' />
</fileset>
</path>
<path id='compiled.class.path'>
<fileset dir='./bin/pkg'>
<include name='*.class' />
</fileset>
</path>
<taskdef resource="axis-tasks.properties" classpathref="axis2.classpath" />
<target name="run" >
<axis-java2wsdl
output="out/TestService.wsdl"
location="http://localhost:8080/axis2/service/TestService"
namespace="service"
classname="TestService">
<classpath refid="compiled.class.path"/>
<mapping namespace="TestService" package="pkg"/>
</axis-java2wsdl>
</target>
here is my file structure:
prj->bin->pkg->TestService.class///////////
prj->src->pkg->TestService.java///////////
prj->build.xml
I get java.lang.ClassNotFoundException: TestService.
Can anybody tell me how to fix it? Thanks so much. !!!!!!!!!!!!!
Is TestService in a package called "pkg", or is it in the default package (i.e., no package)? If it's in a package called "pkg", you want to define your "compiled.class.path" like:
<path id='compiled.class.path'>
<fileset dir='./bin'>
<include name='**/*.class' />
</fileset>
</path>

I want to use NAnt's foreach to iterate files in a folder, how to force alphabetic iteration?

I have an NAnt task "ship" to package my current .sql scripts into a build, then name the build with an incrementing int {######} and copy it to a build folder.
I have another NAnt task which executes those build scripts.
They must execute in order, but in my last attempt, they were not. Can I "force" NAnt to work alphabetically?
FAIL:
<fileset basedir="source\tsql\builds\" id="buildfiles">
<include name="*.sql.template.sql" />
<exclude name="*.sql" />
<exclude name="*asSentTo*" />
</fileset>
<foreach item="File" property"filename">
<in refid="buildfiles">
<echo message="${filename}" />
</in>
</foreach>
PASS:
<foreach item="File" property="filename" in="source\tsql\builds">
<do>
<if test="${string::ends-with(filename,'.sql.template.sql')}">
<echo message="${filename}" />
</if>
</do>
</foreach>
To satisfy my curiosity I tried to reproduce the problem with this script:
<?xml version="1.0"?>
<project name="foreach.test" default="foreach.alpha">
<target name="foreach.alpha">
<foreach item="File" in="C:\foo" property="filename">
<do>
<echo message="${filename}" />
</do>
</foreach>
</target>
</project>
The filenames are printed out in alphabetical order. So conventional use of foreach already seems to be the solution to the problem.
Here is how you do it with a fileset
<fileset id="mySet">
<include name="*.sql" />
</fileset>
<copy>
<fileset refid="mySet" />
</copy>
<foreach item="File" property="filename">
<in>
<items refid="mySet" />
</in>
<do>
<echo message="Copied files: ${filename} to directory: ${Folder}." />
</do>
</foreach>

Publish WebApplication using NAnt

Is it possible to accomplish publish (as in Visual Studio publish on Web Application project) on solution using NAnt? I just can't find the solution.
They key is to use the built-in "_CopyWebApplication" target.
Here is what i do
<target name="compile" description="Compiles the project.">
<exec basedir="." program="${DotNetPath}msbuild.exe" commandline=" src/MyProject.Web/MyProject.Web.csproj /nologo
/t:Rebuild
/t:ResolveReferences;_CopyWebApplication
/p:OutDir=../../output/build/bin/
/p:WebProjectOutputDir=../../output/build/
/p:Debug=${debug}
/p:Configuration=${configuration}
/v:m"
workingdir="." failonerror="true" />
</target>
with the dir structure of:
/project.build
/src/myprojct.sln
/src/myporject.web/myproject.web.csproj
/output
Edit: i also use this to use the YUI compression to compress my css and js
<target name="compress-js">
<foreach item="File" property="filename">
<in>
<items basedir="output/build/assets/javascript/">
<include name="/**/*.js" />
<exclude name="/**/*.min.js" />
<exclude name="/**/*.pack.js" />
</items>
</in>
<do>
<exec basedir="." program="${JavaPath}java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type js --charset utf-8 -o "${filename}" "${filename}"" failonerror="true" />
</do>
</foreach>
</target>
<target name="compress-css" depends="combine-css">
<foreach item="File" property="filename">
<in>
<items basedir="output/build/assets/css/">
<include name="/**/*.css" />
<exclude name="/**/*.min.css" />
<exclude name="/**/*.pack.css" />
</items>
</in>
<do>
<exec basedir="." program="S:\Java\jdk1.6.0_11\bin\java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type css --charset utf-8 -o "${filename}" "${filename}"" failonerror="true" />
</do>
</foreach>
</target>
Using MSBuild beats the purpose of using NAnt, NAnt is something that replaces MSBuild, use the below to do a clean NAnt compilation of Web Application Projects as in VS 2003/2005/2008.
It works for me!
<?xml version="1.0"?>
<project name="MyTest" default="run">
<property name="basename" value="MyTest1x"/>
<property name="debug" value="false"/>
<property name="copytarget" value="c:\temp"/>
<target name="clean">
<delete>
<fileset basedir="${copytarget}">
<include name="bin/${basename}.dll"/>
<include name="**/*.???x"/>
<include name="Web.config"/>
</fileset>
</delete>
</target>
<target name="build">
<mkdir dir="${copytarget}/bin" />
<csc target="library" output="${copytarget}/bin/${basename}.dll" >
<sources>
<include name="*.cs"/>
</sources>
</csc>
</target>
<target name="run" depends="clean,build">
<copy todir="${copytarget}" overwrite="true">
<fileset basedir=".">
<include name="**/*.???x" />
<include name="Web.config" />
</fileset>
</copy>
</target>
</project>
I know this is an old question, but I just learned something, so I decided I'd share: While it is 100% true that the "_CopyWebApplication" target exists and works, as of .NET 4.0 it has been superseded by the "_WPPCopyWebApplication" target in Microsoft.Web.Publishing.targets, which supports new features like web.config transformation syntax, etc.
(reposting to all the similarly worded questions, so don't vote for this one :) )
Here is how you can do it using the MSBUILD task for nant:
<property name="debug" value="AutomatedDebug" />
<property name="configuration" value="Debug;TargetFrameworkVersion=v3.5" />
<msbuild project="src\WebApplication1\WebApplication1.csproj" failonerror="true">
<arg value="/nologo" />
<arg value="/t:Rebuild" />
<arg value="/t:ResolveReferences;_CopyWebApplication" />
<arg value="/p:OutDir=../../build/Debug/WebApplication/" />
<arg value="/p:WebProjectOutputDir=../../build/Debug/WebApplication-Deploy/" />
<arg value="/p:Debug=${debug}" />
<arg value="/p:Configuration=${configuration}" />
<arg value="/v:m" />
</msbuild>
This will compile the WebApplication into a deployable folder, just like using the "Publish" feature from within Visual Studio.