开发者

Force Code Contracts to use sn.exe 4.0

The Code Contracts rewriter uses the Strong Name (sn.exe) utility to resign the rewritten assembly. However in the Output pane of the VS 2010 I see:

Microsoft (R) .NET Framework Strong Name Utility Version 3.5.30729.1

Is there a way to force开发者_如何学Python using the version 4.0 of the sn.exe. Or it doesn't make any difference?


You can modify the MSBuild targets file for Code Contracts to force it to use sn.exe from the version 4.0 SDK. The targets file in question would usually be located at C:\Program Files\Microsoft\Contracts\MsBuild\v4.0\Microsoft.CodeContracts.targets.

The simplest modification would be to replace the line

<CodeContractsSnExe>"$(CodeContractsSdkPath)Bin\NETFX 4.0 Tools\sn.exe"</CodeContractsSnExe>

with a version to specifies the exact path to the copy of sn.exe that you want to run. e.g.:

<CodeContractsSnExe>"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\sn.exe"</CodeContractsSnExe>

If you need to support alternate versions, it would be a better idea to keep the old line, but make the assignment conditional on the value being empty. That way, you could specify an override only when you need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜