Question

Running Moles 0.94 in order to stub out certain types in 3rdparty assemblies which would be otherwise hard to test. Works great locally, tests pass and the solution compiles fine. The first time it compiles it does take quite a while because it generates the mole assemblies (puts them into a subfolder called \molesassemblies) but subsequent times it is much faster - moles outputs the following:

Moles : info : compilation : assembly metadata hash unchanged, skipping code generation

The question is, how do I mimic this behaviour on a build server which re-syncs (tears down) the workspace every time? Is this even possible? (Currently using TFS 2010 as a build server).

I naively tried to check in the contents of the project subfolder called \molesassemblies\ hoping that when msbuild invokes the moles framework during solution compilation it would recognise the assemblies are already there and thereby skip code generation. However, just doing that didnt seem to work. The framework seemed to think it needed to regenerate the code, and then complained that the checked in assemblies were read-only:

00:00:00.00> moles
    Moles : info : metadata : ignoring reference D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\MolesAssemblies\3rdparty.assembly.moles.dll
    Moles : info : metadata : loading D:\Builds\49\mycompany\BUILD-NAME\Sources\3rdPartyBinaries\3rdparty\3rdparty.assembly.dll
    Moles : info : compilation : output assembly name: 3rdparty.assembly.moles
    Moles : info : code : found 2912 types
    Moles : info : code : visibility: exported or assembly(3rdparty.assembly.moles)
    00:00:03.10> code generation
      Moles : info : code : generating code at D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\obj\Release\Moles\sk\m.g.cs
      00:00:03.44> stubs generation
        Moles : info : code : generated 2274 stub types
      00:00:08.32> moles generation
        Moles : info : code : generated 2638 mole types
    00:00:45.13> compiling
Moles : error : compilation : D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\MolesAssemblies\3rdparty.assembly.moles.dll readonly [D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\TestHelpers.csproj]
  00:02:27.44> moles generator 1 errors, 0 warnings
C:\Program Files\Microsoft Moles\bin\Microsoft.Moles.targets(79,5): error MSB3073: The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\obj\Release\Moles\moles.args" exited with code -1009. [D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\TestHelpers.csproj]
  Result: error while copying output (-1009 - 0xfffffc0f)
  MolesAssemblies:
    3rdparty.assembly.moles ignored because already referenced from other location
Done Building Project "D:\Builds\49\mycompany\BUILD-NAME\Sources\Products\Product\Tests\TestHelpers\TestHelpers.csproj" (default targets) -- FAILED.

Any guidance on what I could do to get this working would be appreciated.

Thanks.

Was it helpful?

Solution

Unfortunately there's not a great answer here. Moles assemblies used to be checked into source control and part of a test project, then the Moles team changed this functionality since everytime an API changed people had to check out and in the DLLs and no one really like that as it was cumbersome and annoying. Now just the XML manifest of what to Mole is checked in. Given this, you have a couple of options that I can think of:

1- Change your TFS Build definition to keep your workspace around between builds by setting the Clean Workspace field on the Process tab to None or Outputs and see if that helps

2- Host your Moles assemblies somewhere out of source control and copy them in as a pre-build task on the offending Test project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top