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

Comments (1) -

2/25/2013 11:16:49 AM #

I do get the codecontracts build by tfs but all the test using codecontracts fail.
I also get a warning: Unable to load types from the test source 'path to code contract dll'. Some or all of the tests in this source may not be discovered.

Do you have any idea what I should do to get this working?


Fabian Netherlands

Add comment

About the Author

Larry Spencer

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