code contracts assembly reference bug

Unanswered code contracts assembly reference bug

  • Thursday, July 12, 2012 1:46 PM
     
     

    Hello,

    I am encountering build errors when setting copy local to false for referenced external assemblies.

    Project B depends on Project A

    Project A has referenced an external library (log4net).

    I now have set copy local to false on Project A for the external assembly (log4net).

    Building Project A works fine, Code contract settings for this project are set to Contract Reference Assembly = Build and Perform Runtime Contract Checking = Full.

    Now when building Project B which references Project A, the CodeContractRewrite Target throws the following error:

     

    CodeContractRewrite:
      "C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite" "@Presentation.WPFccrewrite.rsp"
      Reading assembly 'Project A Assembly' from 'Path to Project A assembly' resulted in errors.
    Could not resolve type reference: [log4net]log4net.ILog.
    ccrewrite : error : Rewrite aborted due to metadata errors. Check output window

    Project B has the same Code Contract settings as Project A.

    Settings copy local back to true for the log4net library fixes the problem.

    Setting the 'Extra Contract Library Paths' also fixes the problem, but is not very helpful. The Code Contracts Settings Pane does not allow me to use properties ($(SolutionDir)) and if I edit the path directly in the project file the Code Contracts settings pane overwrites the path when making changes to the settings.

    This is a very strange behavior.

    Does anyone know how to fix this?

    Thanks in advance,

    Martin

All Replies

  • Thursday, July 12, 2012 3:08 PM
     
     

    Hello, 

    Just found another work-around for this problem... 

    Adding the reference to Project B solved the problem and the build succeeds.

    Not a very nice solution, if I have to add references to my projects, which they actually do not need.