1

I build my solution but CC tools are not installed on build server.
So no rewrite was done.

Now I'm curios why msbuild reports build as successfull if not all tasks were finished?

P.S. I'm completely unexperienced in msbuild so if my question sounds stupid I beg you pardon, guys.

Update
Well, I installed locally Code Contracts extension which created additional tab for project options.Then I enabled code contracts checking at run time and added at the very begining of the Main method the following line:

// test for Code Contracts rewrite
// exception is thrown if no rewrite 
Contract.Requires<Exception>(true);

I commited changes to TFS and started the build and it completed succesfully without any warnings. No rewrite was done and my application throws exception.
I've read about Microsoft.CodeContracts.targets file ad found it in CC installation dir but I see no refernces to it inside project file. Only elements like <CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>.

I don't understand where msbuild gets the knowledge about CC and how to apply them.

Update 2
Eventually we installed Code Contracts on Build Server and assembly instrumentation is performed.
Yet it's still not clear what settings are changed during CC installation.

Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

1 Answers1

3

You need to install the tools on the build server as well. The design of the contract tools are such that unless you use Contract.Requires< Exception >(...) one can build and release bits without the use of our tools. If you use Contract.Requires< Exception >(...) however, then you must use the rewriter as the documentation states. Thus, in order for your project to be successfully built, you need to install the tools. MsBuild and VS and C# know nothing of the contract tools and thus cannot warn you about this lack of tool installation.

Hope this helps.

Manuel Fahndrich
  • 665
  • 4
  • 12
  • Yes, we installed it on the build server. But it is interesting how MS Build knows about installed coed contracts tools. Does installer create some records in registry? – Pavel Voronin Apr 25 '13 at 04:39
  • 2
    @voroninp, the CodeContract installer adds an msbuild target file in the standard msbuild directories that gets included after the Common build file. That's how we control the build and invoke the tools as necessary. – Manuel Fahndrich Apr 25 '13 at 14:53