visual-studio 如何找出 $(ProjectDir) 的值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3423538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:19:00  来源:igfitidea点击:

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

visual-studio

提问by Ramesh

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

我在哪里可以执行并找出 的值$(ProjectDir)

采纳答案by leppie

Do a pre/post build step.

执行前/后构建步骤。

Example:

例子:

echo $(ProjectDir)

回答by slugster

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 Eventstab
  • click the Edit pre-buildor Edit post-buildbutton, either is fine
  • in the window that pops up, click the Macrosbutton
  • scroll down the list till you find ProjectDir, in the next pane is its actual value
  • 在解决方案资源管理器中右键单击您的项目,选择属性
  • 选择构建事件选项卡
  • 单击Edit pre-buildEdit post-build按钮,都可以
  • 在弹出的窗口中,单击按钮
  • 向下滚动列表直到找到ProjectDir,在下一个窗格中是它的实际值

回答by Antoni

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

slugster 的回答对我不起作用(很可能是我的错)。

In Visual Studio 2008

在 Visual Studio 2008 中

  1. right click on your project in the Solution Explorer, select Properties
  2. Go to Configuration Propertiesand then to Debugging
  3. Click on the arrow in the CommandField and click the EditButton
  4. In Editclik "Macros>>" You will see there the values of ProjectDir... etc..
  1. 在解决方案资源管理器中右键单击您的项目,选择属性
  2. 转到配置属性,然后转到调试
  3. 单击命令字段中的箭头,然后单击编辑按钮
  4. 编辑中单击“>>”您将看到 ProjectDir... 等的值。

回答by Mona Jalal

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

在 Visual Studio 2015 中,您可以通过单击其他包含目录中的宏,然后单击宏(对我而言构建事件中没有任何内容)来找到 ProjectDir: 在此处输入图片说明

回答by user79878

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

对我来说,它是包含 *.vcxproj 文件的目录的路径。

From http://msdn.microsoft.com/en-us/library/c02as0cs%28v=vs.80%29.aspx:

来自http://msdn.microsoft.com/en-us/library/c02as0cs%28v=vs.80%29.aspx

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

项目的目录(定义为驱动器+路径);包括尾部反斜杠“\”。

回答by Phlox Midas

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.

打开项目属性(Alter+Enter),然后转到“Build Events”,选择任何构建事件,然后选择“Command Line”,单击“Edit”,然后按“Macros >>”按钮。

enter image description here

在此处输入图片说明