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 Stu
I had the same problem with the latest version of Code Contracts. I had installed the Premium Edition on my development PC and the Standard Edition on the build server and was getting the following error due to the Rewriter not running.
Must use the rewriter when using Contract.Requires
It appears that the Standard edition is missing a key file (CodeContractsAfter.targets) that is needed for MSBuild to invoke the Rewriter.
The solution for me was to copy the CodeContractsAfter.targets from C:\Program Files (x86)\MSBuild\4.0\Microsoft.Common.Targets\ImportAfter on my development PC to the corresponding folder on the build server.
Note: The paths weren't identical as my development PC is running Windows 7 64bit and the build server is running Windows Server 2003 32bit. So you'll need to figure out the exact paths for your environment.
If you aren't using the Premium Edition, the contents of the CodeContractsAfter.targets file is:
C:\Program Files (x86)\Microsoft\Contracts\
Just paste the above into a file in the folder mentioned ImportAfter folder.