Bug Fix: Code Contracts compile error in Visual Studio 2015 and Windows 10

September 16, 2015, (updated on October 2, 2015), 1 comment, Software Development

Recently, I had the following compile error in a fresh Visual Studio 2015 installation on Windows 10. The project in question had Code Contracts enabled. The problem was a .targets file with an invalid path:

1>  The system cannot find the path specified.
1>C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v14.0\Microsoft.CodeContracts.targets(296,5): 
  error MSB3073: The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\
  NETFX 4.6 Tools\sn.exe" /R "obj\Debug\MyToolkit.dll" "Default.snk"" exited with code 3.

To fix this problem, open the file

C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v14.0\Microsoft.CodeContracts.targets

in Administrator mode and change

$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.6 Tools\sn.exe


$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\sn.exe

This problem should be fixed in the next release of Code contracts, check out this pull request.

Tags: , , , ,

One response to “Bug Fix: Code Contracts compile error in Visual Studio 2015 and Windows 10”

  1. Mikkel Lund says:

    Thank you so very much. I had this exact problem, and using this fix removed the problem. Thumbs up!

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.