1 out of 3 rated this helpful - Rate this topic

Macros for Build Commands and Properties

Updated: December 2010

You can use these macros anywhere in a project's Property Pages dialog box where strings are accepted. These macros are not case sensitive.

To display the currently available macros, in the column to the right of a property name, click the drop-down arrow. If Edit is available, click it and then in the edit dialog box, click Macros. For more information, see the Specifying User-Defined Values section of Property Pages (C++).

Macros that are marked "Deprecated" are no longer used or have been replaced by an equivalent item metadata macro (%(name)). Macros that are marked "Deprecated; migrated" are also deprecated. And in addition, if the project that contains the macro is migrated from Visual Studio 2008, Visual Studio converts the macro to the equivalent Visual Studio 2010 macro.

Macro

Description

$(RemoteMachine)

Set to the value of the Remote Machine property on the Debug property page. See Changing Project Settings for a C/C++ Debug Configuration for more information.

$(Configuration)

The name of the current project configuration (for example, "Debug").

$(Platform)

The name of current project platform (for example, "Win32").

$(ParentName)

(Deprecated.) Name of the item containing this project item. This will be the parent folder name, or project name.

$(RootNameSpace)

The namespace, if any, containing the application.

$(IntDir)

Path to the directory specified for intermediate files relative to the project directory. This path should have a trailing slash. This resolves to the value for the Intermediate Directory property.

$(OutDir)

Path to the output file directory, relative to the project directory. This path should have a trailing slash. This resolves to the value for the Output Directory property.

$(DevEnvDir)

The installation directory of Visual Studio 2010 (defined as drive + path); includes the trailing backslash '\'.

$(InputDir)

(Deprecated; migrated.) The directory of the input file (defined as drive + path); includes the trailing backslash '\'. If the project is the input, then this macro is equivalent to $(ProjectDir).

$(InputPath)

(Deprecated; migrated.) The absolute path name of the input file (defined as drive + path + base name + file extension). If the project is the input, then this macro is equivalent to $(ProjectPath).

$(InputName)

(Deprecated; migrated.) The base name of the input file. If the project is the input, then this macro is equivalent to $(ProjectName).

$(InputFileName)

(Deprecated; migrated.) The file name of the input file (defined as base name + file extension). If the project is the input, then this macro is equivalent to $(ProjectFileName).

$(InputExt)

(Deprecated; migrated.) The file extension of the input file. It includes the '.' before the file extension. If the project is the input, then this macro is equivalent to $(ProjectExt).

$(ProjectDir)

The directory of the project (defined as drive + path); includes the trailing backslash '\'.

$(ProjectPath)

The absolute path name of the project (defined as drive + path + base name + file extension).

$(ProjectName)

The base name of the project.

$(ProjectFileName)

The file name of the project (defined as base name + file extension).

$(ProjectExt)

The file extension of the project. It includes the '.' before the file extension.

$(SolutionDir)

The directory of the solution (defined as drive + path); includes the trailing backslash '\'.

$(SolutionPath)

The absolute path name of the solution (defined as drive + path + base name + file extension).

$(SolutionName)

The base name of the solution.

$(SolutionFileName)

The file name of the solution (defined as base name + file extension).

$(SolutionExt)

The file extension of the solution. It includes the '.' before the file extension.

$(TargetDir)

The directory of the primary output file for the build (defined as drive + path); includes the trailing backslash '\'.

$(TargetPath)

The absolute path name of the primary output file for the build (defined as drive + path + base name + file extension).

$(TargetName)

The base name of the primary output file for the build.

$(TargetFileName)

The file name of the primary output file for the build (defined as base name + file extension).

$(TargetExt)

The file extension of the primary output file for the build. It includes the '.' before the file extension.

$(VSInstallDir)

The directory into which you installed Visual Studio 2010. 

This property contains the version of the targeted Visual Studio, which might be different that the host Visual Studio. For example, when building with $(PlatformToolset) = v90, $(VSInstallDir) contains the path to the Visual Studio 2008 installation.

$(VCInstallDir)

The directory into which you installed Visual C++ 2010. 

This property contains the version of the targeted Visual C++, which might be different that the host Visual Studio. For example, when building with $(PlatformToolset) = v90, $(VCInstallDir) contains the path to the Visual C++ 2008 installation.

$(FrameworkDir)

The directory into which the .NET Framework was installed.

$(FrameworkVersion)

The version of the .NET Framework used by Visual Studio. Combined with $(FrameworkDir), the full path to the version of the .NET Framework use by Visual Studio.

$(FrameworkSDKDir)

The directory into which you installed the .NET Framework. The .NET Framework could have been installed as part of Visual Studio 2010 or separately.

$(WebDeployPath)

The relative path from the web deployment root to where the project outputs belong. Returns the same value as RelativePath.

$(WebDeployRoot)

The absolute path to the location of <localhost>. For example, c:\inetpub\wwwroot.

$(SafeParentName)

(Deprecated.) The name of the immediate parent in valid name format. For example, a form is the parent of a .resx file.

$(SafeInputName)

(Deprecated.) The name of the file as a valid class name, minus file extension.

$(SafeRootNamespace)

(Deprecated.) The namespace name in which the project wizards will add code. This namespace name will only contain characters that would be permitted in a valid C++ identifier.

$(FxCopDir)

The path to the fxcop.cmd file. The fxcop.cmd file is not installed with all Visual C++ editions.

Date

History

Reason

December 2010

Described a way to display the currently available macros.

Customer feedback.

July 2010

Linked to the "item metadata macro" topic, and improved the macro notation prototype.

Content bug fix.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Is there a build macro for the current source file name being compiled?
FYI
Is there a build macro for the current source file name?
I ask this question because I add a asm file to my solution that needs to set the assembly complier command line, which requires the file name being complied upon.

I don't want to add the name explicitly, so is there a macro for the current source file name?
$(TargetPath) has a bug, when specifying some relative paths.
Details here:
https://connect.microsoft.com/VisualStudio/feedback/details/692848/-targetdir-computes-wrong-for-outdir-starting-with
and here:
http://thetweaker.wordpress.com/2011/10/08/targetdir-bug-or-where-did-my-pdb-go/

it's for building
@paul the macros are for building. not for debugging
Macros don't appear to work on Debug page
It would appear you can't use these macros on the DebugPage. I tried setting $(TargetPath) as the Command line argument on the Debug property page (to run a built assembly as an nunit test fixture), and Nunit reported $(TargetPath) as an invalid filename - it hadn't been expanded. So the statement that you can use these macros anywhere on a project property page where you can enter a string would appear to be wrong.
$(Configuration) vs $(ConfigurationName)
This document discusses $(Configuration), but the list of macros available has $(ConfigurationName) not $(Configuration). $0$0 $0 $0I have seen cases where the values of these are not the same (having displayed both in a PostBuild event), but I have not been able to repeat that.$0 $0$0 $0 $0Does anyone know what the difference is, and/or why the Macros list does not match the descriptions on this web page?$0
Wrong $(TargetDir)
Using vs2005. When I change the Output Directory, that is $(OutDir), I notice that $(TargetDir) does not get updated.  Anyone know why not?
($VSTSDBDirectory) refers to VSTSDB
($VSTSDBDirectory)   Provides a path reference to [Program Files]\Microsoft Visual Studio 10.0\VSTSDB
This is particularly useful for database references to master or msdb .dbschema files, and is a convenient way to resolves the location of these files across machines, rather than depending on a drive letter-based path, which might begin with either c:\program files\... or c:\program files (x86)\... depending upon the platform.
Advertisement