Visual Studio 11 Beta, Code Contracts and Strong Naming
Sunday, April 8, 2012
There is a bug in the Visual Studio 11 beta installer which incorrectly sets the path to the Strong Name tool (sn.exe) in the code contracts targets file. When building an application with Code Contracts enabled, and the assembly is signed, you will get an error 9009 from MS Build, indicating a 3rd party tool (CCRewriter in this instance) failed. This is because the CCRewriter can not find the sn.exe.
The fix is pretty easy, just change the Code Contracts targets file to the correct path. The targets file is located at C:Program Files (x86)MicrosoftContractsMsBuildv4.0Microsoft.CodeContracts.targets. Line 267 should be changed to: