有哪些技巧可以让我的项目每次都在全新的结帐时进行编译?
很多次我都不愿意承认,我曾多次让刚接触项目的人进行检查,却发现他们缺少各种资源、dll 和设置。 我想养成正确的习惯,让我的项目编译顺利,就像重新结帐一样。
关于如何构建我的项目,以便它们在从版本控制中重新签出时不会出现编译问题,有哪些提示或建议?
我开始在我的项目中保留一个“Resources”文件夹,其中包含源代码管理中所有需要的 dll 引用。 其他人可以提出一些建议吗?
More times than I'd like to admit I've had people new to a project do a checkout only to find they are missing various resources, dll's, settings. I'd like to get in the proper habit of having my projects compilation be smooth as can be from a fresh checkout.
What are some tips or suggestions on how to structure my projects so they don't have compilation issues on a fresh check out from version control?
I've started keeping a "Resources" folder in my projects that contain all needed dll references in source control. Can anyone else make some suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
假设您在 Visual Studio 环境中,这里有一些您可能会发现有用的东西,YMMV 当然,请注意我们使用 Subversion,但任何 VCS 工具都应该这样做...
最后提示 - 在完成彻底检查并成功编译后,检查工作副本中是否有任何修改,例如 TortoiseSVN -> 检查是否有修改。 如果检测到更改,则可能需要忽略这些文件。
Assuming you're in a Visual Studio environment, here are some things that you might find useful, YMMV of course and note that we use Subversion, but any VCS tool should do...
Final tip - After you have done a clean checkout and have a successful compilation, check to see if there are any modifications in your working copy, e.g. TortoiseSVN -> Check for modifications. If you have changes detected, then these files probably need to be ignored.
找到一台未使用的旧计算机并将其设置为自动“滚动构建”:
make clean
还不够 - 扫描碎片并将其删除)如果构建或测试失败,请发送包含错误的电子邮件。 包括在 #2 中进行的更改列表。
如果你真的实在找不到机器,那就在虚拟机中进行吧。
Find an older computer that isn't being used and set it up for automatic "rolling builds":
make clean
isn't enough - scan for debris and remove it)If the build or tests fail, send email with the error. Include the list of changes that were picked up in #2.
If you really, really can't find a machine, do it in a virtual machine.
像 nmaven 这样的工具可以帮助解决依赖性问题,(尽管您可能需要查看 java maven 文档以获取信息....)
持续集成工具,例如 cruisecontrol 在每次签入后重复签出并构建您的应用程序,这可以提醒您破坏构建的签入...此外,它们可以运行您的单元测试,从而提醒您签入导致的任何回归......
Tools like nmaven can help with dependency issues, (Although you might have to look to the java maven docs for info....)
Continuous-integration tools like cruisecontrol repeatedly check-out and build your application after each checkin, which can alert you to checkins which break the build... Also, they can run your unit-tests, and thus alert you to any regressions caused by your checkin, too...
*.obj
等...排除这些文件类型意味着当您运行步骤 2 时差异列表中并没有挤满您不打算存储的文件*.obj
and so on ... excluding these file types means that when you run step 2 the list of differences isn't crowded with files which you aren't intending to storeDebian Linux 有一个非常棒的工具,名为
pbuilder
,它创建新安装的系统的映像,然后尝试构建您的代码。 它只适用于 Debian 软件包系统,但你可以窃取这些想法,这真的很好。自动化从 chroot 环境或看起来像全新安装的虚拟机进行构建。 然后,您的构建脚本将安装 DLL 等。 或者您的配置脚本将枚举缺少的依赖项(所有依赖项,而不仅仅是第一个)。
现在是凌晨 1 点,我听起来语无伦次,但有两个想法是核心:
拥有一个可以模拟空白系统的虚拟机或 chroot 目录。 如今,虚拟机可能是最简单的。
调整您的构建系统,直到它自动检查并在您的虚拟机上构建——或者抱怨缺少什么。
调整您的构建系统,
那时,您可以将该过程作为自动化夜间构建的一部分,您将成为一个快乐的露营者:-)
Debian Linux has a really awesome tool called
pbuilder
, which creates an image of a freshly installed system and then attempts to build your code. It works only with the Debian package system, but you could steal the ideas, which are really good.Automate your build from a chrooted environment or a virtual machine that looks like a fresh install. Your build script will then install the DLLs and so on. Or your configure script will enumerate the missing dependencies (all of them, not just the first one).
It's 1am and I'm sounding incoherent, but two ideas are central:
Have a virtual machine or chroot directory that can mimic a blank system. These days a virtual machine is probably easiest.
Tweak your build system until it automatically checks and builds on your virtual machine---or else complains about what is missing.
At that point you can make the process part of an automated nightly build, and you'll be a happy camper :-)
任何资源/DLL/设置都应与源代码一起检查到版本控制中。
它们应该与源代码进行标记和同等对待,这将允许您将这些资源与源相关联,并将源代码/资源/设置视为单个实体。
在我的公司,我们使用 Rational ClearCase。 除了生成的源代码文件(例如,从 MIDL 编译器生成的 .cpp 和 .h 文件)之外,所有内容都会检查到源代码管理中。 正因为如此,大多数构建都相当顺利。
您还需要确保正确设置依赖项,因此当源文件更改时,所有依赖库都将重新构建。
Any resources/DLLs/settings should be checked into version control along with the source code.
They should be labeled and treated equally with the source code, which will allow you to correlate these resources against the source and treat the source code/resources/settings as a single entity.
In my company, we use Rational ClearCase. Everything is checked into source control, with the exception of generated source code files (e.g. .cpp and .h files generated from the MIDL compiler). Because of this, most builds go fairly smoothly.
You also need to ensure that your dependencies are set up properly, so when a source file is changed, all of the dependent libraries will be re-built.
您可以建立一个全面的清单,在每次签入之前查阅 - 但这会非常耗时且容易出错(特别是在多个开发人员中,并不是每个人都具有每次都严格遵循清单的性格特征)。
相反,设置一个简单的持续集成服务器 - CruiseControl.Net 是开源的; JetBrains 的 TeamCity 是免费的 - 每次签入完成时都会检查构建工作。
这样,您就可以确定——而不是因为遵循了清单就推断事情有效。
You could build up a comprehensive checklist that you consult prior to every check-in - but that would be timeconsuming and error prone (especially across multiple developers, not everyone has the personality traits to follow a checklist closely everytime).
Instead, set up a simple Continuous Integration server - CruiseControl.Net is open source; TeamCity by JetBrains is free - that checks the builds work every time a checkin is done.
This way, you know for sure - rather than inferring things work because the checklist was followed.
SCons 是另一个跨平台工作的工具,有助于管理您的依赖项。 与 gnu make 类似,您有一个“scons 文件/脚本” - 事实上它使用 python 为您提供了很大的灵活性。
http://www.scons.org/
(我与 SCons 没有任何关系;我们只需使用它即可)
SCons is another tool that works cross-platform and helps manage your dependencies. Similar to gnu make in the you have a "scons file/script" - and the fact that it uses python gives you a lot of flexibility.
http://www.scons.org/
(I do not have anything to do w/SCons; we just use it)