简体   繁体   English

.NET / SVN:使用预提交挂钩构建项目

[英].NET/SVN : Build project using pre-commit hook

Novice question: 新手问题:

Is it possible to build my project (using BuildEngine or so) if I write a pre-commit hook in C#? 如果我在C#中编写了一个预提交钩子,是否可以构建我的项目(使用BuildEngine或类似的东西)? What I want to do is, build the project upon commit on my dev server and accept the transaction if build succeeds. 我想做的是,在我的开发服务器上提交后构建项目,如果构建成功,则接受事务。 Is it even possible? 可能吗? If so some hints would be highly appreciated. 如果是这样的话,一些提示将不胜感激。

I think this is : - hard to do - awkward 我认为这是:-很难-尴尬

1. Hard to do 1.难做
Your cc .net project is linked to a source control server (here svn). 您的cc .net项目已链接到源代码控制服务器(此处为svn)。 If you want to force a ccnet project in a precommit hook (which you can do by calling ccnet.exe -c configfile.config -p "Project Name" ), you will need to get the source you want to build against and in your case these are not the latests. 如果要在预提交挂钩中强制执行ccnet项目(可以通过调用ccnet.exe -c configfile.config -p "Project Name" ),则需要获取要在其上构建的源如果这些不是最新的。 One solution may be to commit to a branch and then make a cc .net project which would merge the branch into the trunk upon a successful build. 一种解决方案可能是提交到分支,然后创建一个cc .net项目,该项目将在成功构建后将分支合并到主干中。

2. Awkward 2.尴尬
A source control repository is always the code reference, what you commit MUST BE tested and correct. 源代码控制库始终是代码参考,您提交的内容必须经过测试和更正。 CI is here to check the repository integrity, do additionnal tests and automatic deployments. CI在这里检查存储库的完整性,进行附加测试和自动部署。 Thus, there can be commits that break the build but they must be exceptions, validating the build in pre-commit is overkill. 因此,可能有一些提交破坏了构建,但是它们一定是例外,在预提交中验证构建是过大的。

That's why I would recommend that you don't use a CI tool for your hook and that you use one "normally" to tests your builds (your builds would not be broken very often, but the functionnal tests can be wrong). 这就是为什么我建议您不要在钩子上使用CI工具,而建议您“正常”使用一个工具来测试您的构建(您的构建不会经常被破坏,但是功能测试可能是错误的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM