title: Running Moles on a build server - any ideas how to skip code generation?
body: <p>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:</p>
  
  <pre><code>Moles : info : compilation : assembly metadata hash unchanged, skipping code generation
  </code></pre>
  
  <p>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).</p>
  
  <p>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:</p>
  
  <pre><code>00:00:00.00&gt; 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&gt; 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&gt; stubs generation
          Moles : info : code : generated 2274 stub types
        00:00:08.32&gt; moles generation
          Moles : info : code : generated 2638 mole types
      00:00:45.13&gt; 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&gt; 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.
  </code></pre>
  
  <p>Any guidance on what I could do to get this working would be appreciated.</p>
  
  <p>Thanks.</p>