Friday, March 22, 2013

Private accessors and TFS2012 Builds


sometimes old test containing privert accessors will fail the build with Error:
 
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets (14): Object reference not set to an instance of an object.

 

first try to remove the private accessors and use a mocking framework (pex/moles or VS2012 Fakes)
But if due to any reason, you cannot remove the usage of private accessors immediately from your tests, please try changing the TeamTest targets file ("C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets") and see whether running the shadow task in a separate process works or not.

Here are the steps you should do for this: -

  1. Edit the targets file ‘C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamTest\Microsoft.TeamTest.targets’.

  1. Change ExecuteAsTool property (highlighted) from default false to true.

<Target Name="ResolveTestReferences" Condition="'@(Shadow)'!=''">
  <BuildShadowTask
      ExecuteAsTool="True"  <!—Default value is false, change it to true –>
      CurrentResolvedReferences="@(ReferencePath)"
      CurrentCopyLocalFiles="@(ReferenceCopyLocalPaths)"
      Shadows="@(Shadow)"
      ProjectPath="$(ProjectDir)"
      IntermediatePath="$(IntermediateOutputPath)"
      SignAssembly="$(SignAssembly)"
      KeyFile="$(AssemblyOriginatorKeyFile)"
      DelaySign="$(DelaySign)">
 
    <Output TaskParameter="FixedUpReferences" ItemName="ReferencePath"/>
    <Output TaskParameter="NewCopyLocalAssemblies" ItemName="ReferenceCopyLocalPaths"/>
  </BuildShadowTask>
</Target>

  1. Save the file. (and probably restart the machine as well so that the background msbuild processes definitely picks up the change)

 




No comments:

Post a Comment