This stack overflow question:
Microsoft Code Contracts and CI build server
asks how to get code contracts working on a build server without installing Visual Studio 2010. We're trying to do the same. We've followed the steps outlined in the accepted answer, but haven't been able to get it working.
CodeContracts will not install on the build server unless Visual Studio is present. So following the suggestion, we've done the following:
- We copied the contents of
%programfiles%\Microsoft\Contracts\Bin
from a development machine with Visual Studio 2010 Ultimate and Code Contracts Premium installed to the build server. - We also copied the
MSBuild\v4.0
folder that containsMicrosoft.CodeContracts.targets
andMicrosoft.CodeContractAnalysis.targets
.
According to the CodeContracts documentation,
Using msbuild on a project or solution that uses contracts enabled via the VS user interface will perform the same actions as the corresponding build under VS.
This is our use case, we're simply calling MSBuild on our solution file as below. The solution file is created via Visual Studio with all the expected Code Contract options configured for rewriting.
<Target Name="Release">
<MSBuild Projects = "Cofamilies\WebApplication\CofamiliesWeb.sln" Properties="Configuration=Release" />
</Target>
But the rewriter is not getting called.
Does anybody have a suggestion for what we're missing and/or suggested troubleshooting steps?