views:

54

answers:

1

I am trying to configure CruiseControl .net to build our repository code periodically and run the tests included in the solution. I have configured the retrieving code from the svn server and building part. But I am unable to run tests on it. MSBuild keeps on complaining that.

error MSB4057: The target "Test" does not exist in the project.

I also tried running the tests through command line to see if that works with the same error. I used: MSBuild.exe TestProject.csproj /t:Test

My configuration is something like this:

<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>C:\WorkingDir\build\MainProject</workingDirectory>                
        <projectFile>MainProject.csproj</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
        <targets>Build</targets>
        <timeout>900</timeout>
        <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
    </msbuild>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>C:\WorkingDir\build\TestProject</workingDirectory>                
        <projectFile>TestProject.csproj</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
        <targets>Test</targets>
        <timeout>900</timeout>
        <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
    </msbuild>  
    </tasks>

I would appreciate any hint in the right direction.

+2  A: 

You havent explained what test framework you're using, which is pretty key here.

For MSTest, this invocation stuff is part of TFS [as the runner stuff is part of Visual Studio, which is why a Task to run MSTest can not be part of MSBuild, which is part of the .NET Framework -- this is also why MSTest forces [in 2010, a subset of] Visual Studio to be installed on your build server (there are a good few questions around here on that topic)]

For xUnit.net, people do stuff like this

For NUnit there's a task that you can supply a list of files to.

Bottom line - one adds a Test custom target to a .csproj file which triggers the salient MSBuild wrapper task for invoking your test runner.

Ruben Bartelink
sorry about not being more clear. Yes i the test project is of the type MSTest (using VS 2010). I guess that means that i cannot run the tests unless I have a visual studio installed on the build server. Is there no work around? I mean having a Visual Studio installation on the build server seems to defeat the purpose doesnt it?
shake
In 2010 at least there was supposed to be a standalone MSTest build server installer (not sure if this happened - it would be good for you to figure it out and comment on the answer...)See http://stackoverflow.com/questions/954943/how-to-use-mstest-in-continous-integration-without-vs/954979#954979 and http://stackoverflow.com/questions/1062994/running-mstest-exe-publish-on-a-teambuild-server-what-are-the-prerequisites (But you didnt say if you're using 2010). MSTest is as mad as a box of frogs - you'll see lots of xUnit.net sealotry from me around the place as a result of madness like this!
Ruben Bartelink
Yeah i am using VS 2010. I ended up switching to nunit after all. There was an option to install a tester version of visual studio test edition but nunit just seemed easier. And surprisingly easy to migrate to from MSTest. Thanks for your help
shake
@shake: Congrats! BTW xUnit is very easy to mvoe to from NUnit and MSTest too. Just sayin' :P
Ruben Bartelink