开发者

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

Where can I execute and find out the value of $(Proj开发者_Python百科ectDir)?


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


Do a pre/post build step.

Example:

echo $(ProjectDir)


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..


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) :

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


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.

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


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.


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

From https://learn.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 ''.


Tools -> External Tools create command for Powershell.exe or Csc.exe copy exe to c:\ for shorter paths Name it and check Prompt for arguments

now click Tools -> Click name of your tool with dialog displayed, click Argument button and choose $(ProjectDir) or whatever. Your $(ProjectDir) is displayed in Command Line after Powershell.exe or csc.exe Clear Arguments and click argument button again Your next selection is display again after command (repeat to view all 16 environment variables.

this is without executing command but command is required to save.

if you use csc.exe from this path "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\Roslyn\csc.exe" copy Roslyn folder to C:\Roslyn csc.exe needs other files to work, you need whole directory. Roslyn folder is only 34 Mb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜