software development

Visual Studio 2010, C++, Linker and Librarian Output Files, and Target Name

Visual Studio 2010 and its corresponding MSBuild schema files have finally brought C++ project files into the 21st century. C++ project files not only get a new extension (vcxproj), they get some new properties as well, such as TargetName and TargetExtension.

In prior versions of Visual Studio, other than changing the name of the project, it was necessary
to use the Linker’s (DynamicLibrary) or Librarian’s (StaticLibrary) OutputFile properties to change the name of the build artifact.

Librarian OutputFile
Librarian OutputFile

While these properties are still present in Visual Studio 2010, in the latest MSBuild schema (in which there is an error that you’ll run into if you are parsing it manually — there is no “Lib” child of “LinkItem” type in the “ItemDefinitionGroup” element) there is a new way of changing the name of the build artifact. In the General property sheet you can specify a TargetName property which defaults to $(ProjectName).

Target Name and Extension
Target Name and Extension

So even if your project name is a windows application named “HelloWorld” and Product Management says it needs to be called “NoReasonForThisChangeOtherThanWeNeedToDrawAPaycheckSoItNeedsToLookLikeWeAreDoingSomething”, you can simply change the TargetName property and that is the artifact that will be created.

Additionally, if you don’t like the default extension based on project type (Application=exe, DynamicLibrary=dll, StaticLibrary=lib) you can change the target’s extension with the TargetExtension property.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s