none
VS2012 code contracts with a signed assembly

    질문

  • I have an assembly that I've been signing for years. I just tried to add some code contracts to it using Visual Studio 2012. The code contracts, apparently when re-writing the assembly, cannot sign the assembly. This error is issued:

    Assembly 'xyz' has already been rewritten. I, your poor humble servant, cannot rewrite it. Instead I must give up without rewriting it. Help!
    1>  elapsed time: 4355ms
    1>  '"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bin\sn.exe"' is not recognized as an internal or external command,
    1>  operable program or batch file.
    1>C:\Program Files (x86)\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets(274,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bin\sn.exe" /R "obj\Debug\xyz.dll" "Properties\xyz.snk"" exited with code 9009.

    The problem seems to be that the v.70A sn.exe lives here:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bin\sn.exe

    But the v8.0A version has been moved (of course) to here:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe

    There is now a directory named "NETFX 4.0 Tools" between the "bin" and the sn.exe.

    Looking at the Microsoft.CodeContracts.targets(274,5) file I would guess that the code contracts code is not properly defining the CodeContractsSdkPath macro and/or the CodeContractSnExe macro properly, given that v8.0A has up and moved the location of sn.exe.

    Is there any work-around to get my build to work with code contracts, other than not signing the assembly?


    -glenn-

    2012년 8월 22일 수요일 오후 7:42

답변

  • What version of Code Contracts are you using? This should have been fixed in the latest release (1.4.50813.1). If you are using that version, then can you please package a repro into a zip file and send it to me?

    Sorry for the problem!


    Mike Barnett

    2012년 8월 22일 수요일 오후 8:03

모든 응답

  • What version of Code Contracts are you using? This should have been fixed in the latest release (1.4.50813.1). If you are using that version, then can you please package a repro into a zip file and send it to me?

    Sorry for the problem!


    Mike Barnett

    2012년 8월 22일 수요일 오후 8:03
  • Ah, that seems to have been the issue. I was running 1.4.50237.0, which I had only installed a few weeks ago. Should have thought to check for an updated version, what with VS2012 just being released and all. Thanks for the help, Mike.

    -glenn-

    2012년 8월 22일 수요일 오후 8:10
  • Phew! You had me worried there! I'm glad it worked.

    Mike Barnett

    2012년 8월 22일 수요일 오후 8:14