问题描述
我们迁移到.NET 4和实施新的契约式设计的功能非常感兴趣。
正如我们所知道的 code合同引擎需要安装的
和VS终极或premium(静态检查)。
下面是我的问题:
- 我可以用code合同改写而对CI的构建服务器(TeamCity的)?安装VS
- 有没有的MSBuild任务执行合同检查?
- 请您使用code合同的验证与CI构建?
是的。构建服务器上安装codeContracts。 (如果拒绝安装的机器上没有的Visual Studio,只需复制下面列出的文件,它们的依赖,到构建服务器。)一旦安装后,你会发现安装到%ProgramFiles%\ Microsoft提供的codeContract工具\合同\ BIN。在该目录中,有4个可执行文件,你会感兴趣的:
-
ccrewrite.exe - 二进制重写。这应当编译后执行。原来你的合同到运行时检查或任何你指定你想让他们变成了。
-
ccrefgen.exe - 这可以生成合同参考组件旁边的组件。如果你运送的DLL由其他单位被消耗,这非常有用。
-
cccheck.exe - 静态检查。在构建服务器,你运行该工具在包含合约的组件,它会吐出警告和信息,因为它遇到的潜在问题。
-
ccdocgen.exe - 这从您的code合同生成的XML文档。你可能想用这个,如果你被其他方出货的dll与合同食用,或者如果你只需要在你的code内部文档。
是的。有2的MSBuild任务运费codeContracts:在同一codeContracts安装目录,检查出的MSBuild \ [Framework版本]文件夹中。在该目录中,有2个文件,应该帮助你:微软codeContracts.targets和Microsoft codeContractAnalysis.targets。
按照codeContracts文档,
正如你所看到的,这是可能的,支持的整合工具导入CI通过的MSBuild目标的基础之上。
假设你的意思是静态与警告/邮件检查,我做这个个人,但还没有一个大项目做到了这一点。
我希望这有助于!
帽尖乔恩斯基特的 C#在深度书的命令行工具的解释。
We are migrating to .NET 4 and very interested in implementing new Design By Contract capabilities.
As we know Code Contract engine requires installation of Code Contract addin
and VS Ultimate or Premium (for static checking).
Here is my questions:
- Can I use code contract rewritingwithout installing VS on CI build Server (TeamCity)?
- Is there anymsbuild tasks to execute Contract checking?
- Do you use Code Contract's validation with CI builds?
Yes. Install CodeContracts on the build server. (If it refuses to install on a machine without Visual Studio, just copy the files listed below, and their dependencies, onto the build server.) Once installed, you'll find the CodeContract tools installed in %programfiles%\Microsoft\Contracts\Bin. In that directory, there are 4 executables you'll be interested in:
ccrewrite.exe - The binary rewriter. This should be executed after compilation. It turns your contracts into runtime checks or whatever you specify you want them turned into.
ccrefgen.exe - This can generate contract reference assemblies alongside your assemblies. This is useful if you're shipping dlls to be consumed by other parties.
cccheck.exe - The static checker. On the build server, you'd run this tool over your assemblies containing contracts, and it will spit out warnings and messages as it encounters potential problems.
ccdocgen.exe - This generates XML documentation from the contracts in your code. You might want to use this if you're shipping dlls with contracts for consumption by other parties, or if you just need internal docs on your code.
Yes. There are 2 MSBuild tasks shipping with CodeContracts: in the same CodeContracts installation directory, check out the MSBuild\[framework version] folder. In that directory, there are 2 files that should help you out: Microsoft.CodeContracts.targets and Microsoft.CodeContractAnalysis.targets.
According to the CodeContracts documentation,
As you can see, it is possible and supported to integrate the tools into CI builds via the MSBuild targets.
Assuming you mean static checking with warnings/messages, I've done this personally, but haven't done this on a big project.
I hope this helps!
Hat tip to Jon Skeet's C# In Depth book for explanation of the command line tools.
这篇关于微软code合同和CI构建服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!