Gics file not found with WPF and code contracts

I have a WPF project that compiles just fine. However, when I enable the code contracts, I get a lot of errors like:

file 'C:\MyProject\obj\Debug\MyFile.g.i.cs' could not be found

      

Is there a workaround?

+2


source to share


3 answers


Just FYI ... This bug was fixed in the latest version of Code Contracts (v1.2.21023.14 released Oct 22).



+1


source


Can you elaborate on your stages of reproduction in more detail? Meaning files ending in .gics are files created specifically to include intellisense in running projects. They are not part of the build process and probably should not be used by code contracts. I am not an expert on code contracts by any means, although I could be wrong on this question.



0


source


I've posted a registry and workaround for this issue on the Code Contracts forum. Here's the url:

http://social.msdn.microsoft.com/Forums/en-US/codecontracts/thread/4f2af748-1db1-4175-abf0-fbcc82f177ee


The short answer is that the error occurs whenever you have multiple projects that reference each other in a solution, and one of the child projects is a WPF control library. To work around this issue, you can either disable contract checking for the parent project (those referenced by other projects), or add a post-build event to the offending child project to create * .gics that look for rewriting the contract code.

For example, create a blank text file in the root directory of your child project and name it "Blank.txt". Then add the following command as a post-build event in this project:

copy "$(ProjectDir)Blank.txt" "$(ProjectDir)obj\$(Configuration)\GeneratedInternalTypeHelper.g.i.cs"

      

Copy this line as many times as necessary, one for each missing file.

0


source







All Articles