There are bunch of macros that Visual Studio uses in project settings which are listed here. I am unable to locate where are these macros or identifiers defined in the actual script file (not in project settings).
In my case I am trying to change the output folder for a project to that of the solution debug or release folder (one level up) but changing 'Output Directory' in project settings has no effect.
There is no mention of these macros in .vcxproj file either so I really don't know where they defined? I am most interested in the $(OutDir)
that I want to change to solution debug/release folder. Does anyone knows where these are defined?
$(OutDir) is a Visual Studio Build Property Macro. You can see the values of macros using the Macros >> button in many Properties dialogs. For instance, in Properties->General->Output Directory, click the dropdown in the value text box, choose Edit..., and in the resulting dialog, click the Macros >> button.
Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.
View the current properties and macrosSelect Edit and then in the Edit dialog box, choose the Macros button. The current set of properties and macros visible to Visual Studio is listed along with the current value for each.
In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.
The majority of those macros are defined in the MSBuild targets file that is included in every VS2010 project. Somewhere in your project file, probably near the bottom, you will find a line like this:
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
If you follow the chain of path variables back you will eventually find the folder that contains Microsoft.Cpp.targets
, which itself will contain:
<Import Project="Microsoft.Common.targets" />
In this file you'll find the following note:
Several properties must be set in the main project file, before using this .TARGETS file. However, if the properties are not set, we pick some defaults.
OutDir: Indicates the final output location for the project or solution. When building a solution,
The defaults that MSBuild picks is to default $(OutDir)
to $(OutputPath)
if it's not explicitly set. $(OutputPath)
is defined in your project file, so changing that property before the targets file gets included will change the default value of $(OutDir)
. You can also just specify a value for $(OutDir)
on the msbuild
command line using /p:OutDir=bin\DebugElsewhere
or whatever and that will override whatever defaults MSBuild wants to use. (This is what TFSBuild does, for example, to get everything in a solution dumped into the same folder.)
Also, for possible future reference, most of the remaining macros are also defined in this file, somewhat further down:
<PropertyGroup>
<TargetDir Condition="'$(OutDir)' != ''">$([MSBuild]::Escape($([System.IO.Path]::GetFullPath(`$([System.IO.Path]::Combine(`$(MSBuildProjectDirectory)`, `$(OutDir)`))`))))</TargetDir>
<TargetPath Condition=" '$(TargetPath)' == '' ">$(TargetDir)$(TargetFileName)</TargetPath>
<ProjectDir Condition=" '$(ProjectDir)' == '' ">$(MSBuildProjectDirectory)\</ProjectDir>
<ProjectPath Condition=" '$(ProjectPath)' == '' ">$(ProjectDir)$(ProjectFileName)</ProjectPath>
.
.
.
</PropertyGroup>
In Visual Studio 2010, the main project settings will define an output folder, the macro that is set from this folder assignment is $(OutDir). There are other predefined macros that you cannot modify, but this one you can.
If I understand what you're trying to do, then follow these steps:
Note: If you have multiple platform targets (win32 and x64 for example) this is a little more involved, but not that bad. Hope this helps.
EDIT OP also would like the PDB and incremental link files not to be published in the same folder, but does want the import library published there. So.....
To change the location where the PDB file is created:
The incremental link file must be (to my knowledge) in the same folder as the final target. You can disable incremental linking if you want, however. This is done at the following location:
To move where the import library is built.
Don't ask me how to get rid of the export-list file (.exp) because I honestly don't know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With