Code Contracts not Working on TFS Build?

by Larry Spencer Thursday, July 21, 2011 9:54 AM

Today's puzzle was why Code Contracts seemed functional in the unit tests on my development machine, but not on our TFS build server. Was there something special about MSBuild? No, not this time. There were two causes.

In some cases, the projects for the Code-Contracted assemblies were set to use Code Contracts on the Debug configuration but not Release. D'oh!

The less obvious problem was that Code Contracts were not installed on the build server. No, they are still not part of the .NET Framework, even with version 4.0. To see whether they are installed, you can go to Control Panel -> Add/Remove programs and look for Microsoft Code Contracts (devlabs_TS), followed by a version number. You can also do Start -> Programs and look for Microsoft Code Contracts.

I hope this helps if you're having the same problem.

Tags: , ,

All | General

About the Author

Larry Spencer

Larry Spencer develops software with the Microsoft .NET Framework for ScerIS, a document-management company in Sudbury, MA.