views:

105

answers:

1

Using Team Foundation Build, I'm invoking the xunit.net xunit task, which is /platform:AnyCpu, but my TeamBuild invocation of the TFSBuild.proj is vanilla.

I have a number of tests that are x64 specific (`/platform:x64'), which choke with an ImageFormatException. I have also a test asembly that's marked x86 so it can't be all or nothing.

NUnit has a platform switch on the MSBuild task, xunit doesnt.

I can think of the following approaches:

  1. invoke a 64 bit msbuild child task to invoke the xunit task - there isnt a ToolPath param, so if that's a good idea, what's the cleanest Exec task syntax to do that, passing in the child environment?
  2. special case the invocation of the 64 bit with xunit.console.x64
  3. switch the entire TeamBuild over to x64 and special case the x86 (but that just lands me in the inverse situation of needinn to special case the x86). (I also assume that other than having to make sure custom tasks are in the right PROGRA~...\MsBuild dir, there's probably going to be more hassle)

What have others had success with in handling issues like this?

+2  A: 

xUnit.net runs its tests inside the same process as the runner, in a separate AppDomain. Since MSBuild is flagged as 32-bit-only, any tests run with the MSBuild xunit task must run in 32-bit mode.

The simplest work-around is to not use the MSBuild task, but instead to shell out to the console runner. Since that creates a new process, it will run in 64-bit mode by default. Also, if you're using the 1.5 beta, we have included EXEs which can force 32-bit mode (xunit.console.x86.exe), which solves your 32- vs. 64-bit test issues.

Brad Wilson
Thanks for the confirmation of the options. While TeamBuild is very x86 centric in VS08SP1, msbuild itself has an x64 variant. So for now I've used option 1 - I do an exec of the Framework64 msbuild which then pulls in the [anycpu] xunit task in x64 mode and runs as desirede. This works out neatest in my context as I'm already using an MSBuild MSBuild task to iterate over a set of test assemblies in an ItemGroup. ... does this make any sense?
Ruben Bartelink