Search code examples
.netversion-controlbuild-processvcs-checkout

What are some tips to make my project compile on a fresh checkout every time?


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?


Solution

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