How can I find out the value of $(ProjectDir)?

Visual Studio

Visual Studio Problem Overview


Where can I execute and find out the value of $(ProjectDir)?

Visual Studio Solutions


Solution 1 - Visual Studio

To find out what it is right now (rather than at build time, where it may be different depending on what is going on):

  • right click on your project in the Solution Explorer, select Properties
  • select the Build Events tab
  • click the Edit pre-build or Edit post-build button, either is fine
  • in the window that pops up, click the Macros button
  • scroll down the list till you find ProjectDir, in the next pane is its actual value

Solution 2 - Visual Studio

Do a pre/post build step.

Example:

echo $(ProjectDir)

Solution 3 - Visual Studio

The answer from slugster did not work for me (most possible my fault).

In Visual Studio 2008

  1. right click on your project in the Solution Explorer, select Properties
  2. Go to Configuration Properties and then to Debugging
  3. Click on the arrow in the Command Field and click the Edit Button
  4. In Edit clik "Macros>>" You will see there the values of ProjectDir... etc..

Solution 4 - Visual Studio

In Visual Studio 2015, you can find ProjectDir by clicking on Macros in additional Include Directories and then clicking on Macros (for me there was nothing in Build Events) : enter image description here

Solution 5 - Visual Studio

Open the project properties (Alter+Enter) and then go to "Build Events", select any of the build events, then select "Command Line", click "Edit", then press the "Macros >>" button.

enter image description here

Solution 6 - Visual Studio

For me it was the path to the directory containing *.vcxproj file.

From https://docs.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties:

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

Solution 7 - Visual Studio

Same here in Visual Studio 2019, you can find ProjectDir by clicking on Macros in additional Include Directories and then clicking on Macros (for me there was nothing in Build Events), like the answer in above Visual Studio 2015.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRameshView Question on Stackoverflow
Solution 1 - Visual StudioslugsterView Answer on Stackoverflow
Solution 2 - Visual StudioleppieView Answer on Stackoverflow
Solution 3 - Visual StudioAntoniView Answer on Stackoverflow
Solution 4 - Visual StudioMona JalalView Answer on Stackoverflow
Solution 5 - Visual StudioPhlox MidasView Answer on Stackoverflow
Solution 6 - Visual Studiouser79878View Answer on Stackoverflow
Solution 7 - Visual StudioShizheng ZhangView Answer on Stackoverflow