有哪些技巧可以让我的项目每次都在全新的结帐时进行编译?

发布于 2024-07-11 07:51:39 字数 221 浏览 9 评论 0原文

很多次我都不愿意承认,我曾多次让刚接触项目的人进行检查,却发现他们缺少各种资源、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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

猫九 2024-07-18 07:51:39

假设您在 Visual Studio 环境中,这里有一些您可能会发现有用的东西,YMMV 当然,请注意我们使用 Subversion,但任何 VCS 工具都应该这样做...

  • 将所有(或尽可能多的)依赖项放在下面版本控制并在您的项目中引用它们。 我们使用 Subversion 外部来管理它。
  • 不对标准输出目录(bin、obj)进行版本控制,即使用 svn:ignore
  • 同样,忽略版本控制用户项(*.user、*.suo)
  • 也不对配置文件(App|Web.config)进行版本控制相反,创建一个 App.default.config 并在您的项目 BeforeBuild 任务中将此文件复制到 App.config。 这允许您通过使用 RegEx 和令牌来设置每个开发人员或构建服务器的编译,它还允许您删除 CI 构建上的任何现有 App.config 文件,以确保每次都是原始构建。 这也使得开发人员可以随意修改配置,而不必打扰其他人,直到他们准备好为止,即更新 App.default.config。
  • 对其他一切进行版本控制:)
  • 如果您需要对编译后的二进制文件(MSI、DLL 输出等)进行版本控制,请在 AfterBuild 目标项目(wixproj 等)中将输出复制到受版本控制的另一个目录。 使用 Subversion 的一个技巧是,您可以添加/提交到 svn:externals 目录,该目录允许您将库等推送到引用它们的项目中。

最后提示 - 在完成彻底检查并成功编译后,检查工作副本中是否有任何修改,例如 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...

  • Place all (or as many as possible) dependencies under version control and reference these in your projects. We use Subversion externals to manage this.
  • Don't version control standard output directories (bin, obj), i.e. use svn:ignore
  • Likewise, ignore version control user items (*.user, *.suo)
  • Also don't version control configuration files (App|Web.config), instead, create an App.default.config and in your projects BeforeBuild task copy this file to App.config. This allows you to get fancy by using RegEx and tokens to setup compilations per developer or build server, it also allows you to delete any existing App.config files on CI builds to ensure a pristine build every time. This also allows developers to muck around with configurations without having to disturb everyone else until they are ready, i.e. update App.default.config.
  • Version control everything else :)
  • If you need to version control binaries (MSI, DLL output, etc) as a result of your compilation, in your AfterBuild target project (wixproj, etc) copy the output to another directory which is under version control. One tip using Subversion is that you can add/commit to an svn:externals directory, which allows you to push libraries, etc out to project which reference them.

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.

太阳哥哥 2024-07-18 07:51:39

找到一台未使用的旧计算机并将其设置为自动“滚动构建”:

  1. 等待有人签入更改
  2. 更新到所有文件的最新版本。
  3. 清理所有非源代码控制文件(make clean 还不够 - 扫描碎片并将其删除)
  4. 运行单元测试。
  5. 每天一次,保存成功运行的二进制文件。 称其为当天的“官方版本”。

如果构建或测试失败,请发送包含错误的电子邮件。 包括在 #2 中进行的更改列表。

如果你真的实在找不到机器,那就在虚拟机中进行吧。

Find an older computer that isn't being used and set it up for automatic "rolling builds":

  1. Wait until someone checks in a change
  2. Update to the latest version of all files.
  3. Clean out all non-source control files (make clean isn't enough - scan for debris and remove it)
  4. Build.
  5. Run unit tests.
  6. Once a day, save binaries from a successful run. Call it the "official build" for the day.

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.

忘东忘西忘不掉你 2024-07-18 07:51:39

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...

东京女 2024-07-18 07:51:39

还有人可以提出一些建议吗?

  1. 将您需要构建的文件保存在一个地方(一个目录及其子目录)...大多数版本控制系统将其称为“工作目录”您的
  2. 版本控制软件有一个命令来列出工作目录中的内容之间的差异目录和受版本控制的内容...此“差异”包括工作目录中存在的文件和不受版本控制的文件
  3. 调整版本控制软件以排除(从步骤 2 显示的列表中)您类型的文件不想存储...例如,您可能只想存储源代码,并排除 *.obj 等...排除这些文件类型意味着当您运行步骤 2 时差异列表中并没有挤满您不打算存储的文件
  4. 考虑拥有一台构建机器,它会自动执行签出和构建(如果“构建被破坏”,它会向您发送电子邮件)

Can anyone else make some suggestions?

  1. Keep the files, which you need to build, in one place (one directory and its subdirectories) ... most version control systems call this your "working directory"
  2. Your version control software has a command to list the differences between what's in your working directory and what's under version control ... this "difference" includes files which exist in the working directory and which aren't under version control
  3. Tune your version control software to exclude (from the list displayed by step 2.) files whose type you don't want to store ... for example, you might want to store only source code, and exclude *.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 store
  4. Consider having a build machine, which automatically does check-out-and-builds (and which emails you if ever the 'build is broken')
旧情别恋 2024-07-18 07:51:39

Debian 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 :-)

您的好友蓝忘机已上羡 2024-07-18 07:51:39

任何资源/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.

习ぎ惯性依靠 2024-07-18 07:51:39

您可以建立一个全面的清单,在每次签入之前查阅 - 但这会非常耗时且容易出错(特别是在多个开发人员中,并不是每个人都具有每次都严格遵循清单的性格特征)。

相反,设置一个简单的持续集成服务器 - 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.

三寸金莲 2024-07-18 07:51:39

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文