This documentation is archived and is not being maintained.

Macros in Project System Properties

This section discusses how to work with the Visual C++ project system object model from script and add-ins.

Macros can be present in almost any string property that you obtain from any object in the object model. The exceptions to this rule are:

  • Name property on any interface (VCPlatform, VCProject, VCFile, VCFilter, VCConfiguration, VCFileConfiguration, VCStyleSheet).
  • ItemName property on any interface (VCProjectItem and all derived interfaces)
  • Kind property on any interface (VCProjectItem and all derived interfaces)
  • FullIncludePath property on any interface (VCCLCompilerTool, VCResourceCompilerTool, VCMidlTool)
  • ToolName property on any interface (all tools)
  • ToolPath property on any interface (all tools)
  • VCProject interface's ProjectDirectory and ProjectFile properties.
  • VCFile interface's Extension property.
  • VCFilter interface's UniqueIdentifier, CanonicalName, and Filter properties.
  • VCStyleSheet interface's StyleSheetName and StyleSheetFile properties.

When a property returns a value that may contain macros, use the closest property container to evaluate it. The property containers, in order of scope, are:

  • VCFileConfiguration
  • VCConfiguration
  • VCPlatform
  • VCProjectEngine

For a file or tool on a file configuration, the property container would be the VCFileConfiguration object for the desired configuration. For the project, this would be the VCConfiguration object for the desired configuration. You use the closest property container because the farther away you get, the fewer macros that can be expanded properly. In other words, when you move from a VCFileConfiguration to a VCConfiguration object to do your evaluation, you lose the context for all of the $(Input*) macros. When you move from a VCConfiguration to a VCProjectEngine or VCPlatform object, you lose the context for all macros that are not system wide.

The following table shows examples of how macros would be evaluated in various contexts. Given,

  • File is c:\myidls\stuff.idl
  • Project is c:\Soln\Proj\Proj.vcproj
  • Solution is c:\Soln\Soln.sln
  • Platform is Win32
  • Intermediate directory is DebugInt
  • Output directory is c:\MyOutputs
  • Debug configuration
  • Output name is Game.exe
Macro File configuration    ProjectConfig VCProjectEngine and VCPlatform
InputDir c:\myidls\ c:\Soln\Proj Not applicable
InputName stuff Proj Not applicable
InputPath c:\myidls\stuff.idl c:\Soln\Proj\Proj.vcproj Not applicable
InputFileName stuff.idl Proj.vcproj Not applicable
InputExt .idl .vcproj Not applicable
IntDir DebugInt DebugInt Not applicable
OutDir c:\MyOutputs c:\MyOutputs Not applicable
ProjectDir c:\Soln\Proj\ c:\Soln\Proj\ Not applicable
ProjectName Proj Proj Not applicable
ProjectExt .vcproj .vcproj Not applicable
TargetDir c:\MyOutputs\ c:\MyOutputs\ Not applicable
TargetPath c:\MyOutputs\Game.exe c:\MyOutputs\Game.exe Not applicable
TargetName Game Game Not applicable
TargetFileName Game.exe Game.exe Not applicable
TargetExt .exe .exe Not applicable
ConfigurationName Debug Debug Not applicable
RemoteMachine Set at project level Set at project level Not applicable
PlatformName Win32 Win32 Not applicable
SolutionDir c:\Soln c:\Soln c:\Soln
SolutionName Soln Soln Soln
SolutionPath c:\Soln\Soln.sln c:\Soln\Soln.sln c:\Soln\Soln.sln
SolutionFileName Soln.sln Soln.sln Soln.sln
SolutionExt .sln .sln .sln
VCInstallDir <VC install dir>\ <VC install dir>\ <VC install dir>\
VSInstallDir <VC install dir>\ <VC install dir>\ <VC install dir>\
FrameworkDir <COM+ dir>\ <COM+ dir>\ <COM+ dir>\
FrameworkVersion Common language runtime version used by the development environment Common language runtime version used by the development environment Common language runtime version used by the development environment
DevEnvDir Location of devenv.exe Location of devenv.exe Location of devenv.exe
Environment macros According to environment According to environment According to environment

Notice that what you pick for the source of your evaluator can significantly change how things evaluate out, particularly for things closely related to file names.

See Also

Visual C++ Extensibility Object Model

Show: