c# - CodeContracts fails the build for seemingly no reason -
i have c# pcl project uses code contracts. on teamcity project fails build, looked build successful locally. build log claim build did fail, gives no reason @ all.
'fail build on warnings' disabled.
i single strange warning:
codecontracts: not find method/type 'system.diagnostics.contracts.pureattribute' in assembly '[project path]\packages\microsoft.net.http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\system.net.http.dll'
searching google gave me one relevant result has same problem. has no responses besides bumping.
i find line peculiar:
c:\windows\system32******.dll (1,1): message : codecontracts: checked 3154 assertions: 2821 correct (333 masked)
why binary located in system32? didn't think msbuild had write access folder...
the issue seems default looks contract types in microsoft.contracts (per spec) doesn't work because microsoft.contracts not using. i'm using system.diagnostics.contracts, located in mscorlib. doesn't tell me this, rather non-sensical. started looking through source code , found offending code in opinion code of poor quality, gave on finding issue , creating pull request.
however solution simple when know: need override default contract library microsoft.contracts mscorlib, add following command line of static analyzer:
-cclib mscorlib
this worked me @ least. still think caused 2 bugs in code contracts:
- it fails build because of warning.
- it tries locate
pureattribute
in wrong assembly.
Comments
Post a Comment