views:

168

answers:

1

I am setting up a CI system for VS2008/C# desktop project, nothing fancy, just a build/test cycle. CI will be running under Hudson using MSBuild/MSTest, but I can't seem to decide on a how to do a few things, maybe you can help me out?

My options for running the project in the CI are:

  • Run the .sln directly from MSBuild
  • Run the .csproj directly from MSBuild
  • Create a separate MSBuild project referencing the .sln or .csproj as an MSBuild task
  • Create a separate MSBuild project importing some stuff (property groups or item groups) from the .csproj

If I wouldn't need to run tests, I would most probably just used the 1st option (run the .sln with MSBuild). But I need to add a task for running the tests, so I can't seem to decide if I should add the task/target to the .csproj's or do it in a separate project. One thing I want to achieve is that when I change my .sln or one of the .csproj, ideally I shouldn't have to touch anything else to be able to keep running successfully in the CI.

Another question is around running the MSTest - is Exec task sufficient or should I write/use some MSTest task (can't seem find one on the .Net)

+1  A: 

The Test task is a built-in task for MSBuild in .NEt 3.5 Framework, as is code coverage. Just search on the BeforeTest and CoreTest-targets on MSDN. Not very hard, just include something like:

   <ItemGroup>
      <TestContainer Include="$(OutDir)\BuildTestProject.dll" />
   </ItemGroup>

   <ItemGroup>
      <MetaDataFile Include="$(SolutionRoot)\BuildTest.vsmdi" />
   </ItemGroup>

   <PropertyGroup>
      <RunConfigFile>$(SolutionRoot)\LocalTestRun.testrunconfig</RunConfigFile>
   </PropertyGroup>

should work..

Bart Janson
Nope, can't seem to make it work. RunConfigFile is a property on a TestToolsTask, which is a part of Team Foundation Build. And TFS is not in the picture for me.
Sergey Aldoukhov
Ah, didn't know it was TFBuild only, in that case, you should indeed use MSTest by calling an Exec-task. Should be plenty of samples on the net.
Bart Janson