Visual Studio Build Configuration Tip

I’ve received several emails recently from users of my VC Build Hook utility that mention switching the ‘UseVC7Paths’ setting on and off depending on the build configuration they are working on. If you are doing this, you need to change your project structure!

Build configurations in Visual Studio 6 and later are logically attached to the solution, not to an individual project as they were in older Visual Studio versions. What happens is that programmers find it easy to add a new build configuration to an existing ObjectARX wizard created project for targeting a new release of AutoCAD — unfortunately those configurations end up belonging to the entire solution instead of just one project. Since VC Build Hook cannot be set on a per-configuration basis, they end up having to change the project setting depending on which configuration they are building. That’s bad, very bad!

The correct way to handle this situation is to create new projects, not new build configurations. Yes, it’s a bit more work, and it would be nice if Microsoft added an easy way to clone a project, but them’s the breaks. Targeting different AutoCAD releases requires project-level changes, so you must create a new project instead of trying to get by with a new build configuration. You can and should share source code files between the projects, however.

When I create a new multi-target solution that e.g. targets AutoCAD 2000 – AutoCAD 2008, I structure the project files on my hard drive like this:

Solution (.sln file)
ARXProject (ARX module source files)
 +ARXProject.15 (.vcproj file)
 +ARXProject.16 (.vcproj file)
 +ARXProject.17 (.vcproj file)
DBXProject (DBX module source files)
 +DBXProject.15 (.vcproj file)
 +DBXProject.16 (.vcproj file)
 +DBXProject.17 (.vcproj file)

When starting a new project, I first use the wizard to create a default project structure and source code files for the current AutoCAD release. Once I’ve got that set up the way I want (including moving the project file into a subdirectory and modifying the source file paths appropriately, as well as setting the _ACADTARGET preprocessor macro), I clone projects by copying the .vcproj files and editing the copies in a text editor to give them a new GUID, then recreate my solution’s project structure from scratch by dragging and dropping the project files back into the solution and editing them as necessary.

If you need to target multiple AutoCAD releases from a single project, invest the time to set your solution up this way (and follow the other advice on my ARX tips page!), otherwise you will find yourself constantly fighting the system.

Leave a Reply

Your email address will not be published. Required fields are marked *