views:

59

answers:

1

A found an article (Extend the Visual Studio Build Process) that explained how to override build targets in a C# project file. I tested this, and it seems to work well. However, what I really want to do is override a build target in a C++ project (with Visual Studio 2005). The problem is that C++ projects use different XML. Instead of having <project> as the root, C++ projects have <VisualStudioProject> as the root. When I add the <target> tag to a C++ project file and try to open the project in Visual Studio, I get this error:

The following error has occurred during XML parsing:

File: [Path to Project File].vcproj Line: 304 Column: 30 Error Message: Element 'Target' is unexpected according to content model of parent element 'VisualStudioProject'.

The file '[Path to Project File].vcproj' has failed to load.

How can I override a Visual Studio build target for a C++ project? Or is there a better way to customize what happens during a C++ build?

+1  A: 

In Visual Studio 2005 there are no build "targets" for C++ builds as the C++ build system does not use MSBuild.

However, VC++2005 defines the Pre-Build, Pre-Link, Post-Build Events as well as the ability to add a Custom Build Step for non-standard files.

You may be able to achieve what you want using these settings.

Note:

  • VC++2005 projects can be built using MSBuild, it's just not what Visual Studio does out of the box.
  • Visual Studio 2010 uses MSBuild for all project types.
Martin
Unfortunately, I want to modify the "Clean" build. I don't think I can achieve what I want to do with Pre-Build, Pre-Link, and Post-Build because those run all the time for all builds. Unless there is a way to set up conditional build steps based on the type of build, it looks like I might be stuck.
CyBri2000