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
How can I find out the value of $(ProjectDir)?
提问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-build或Edit 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 中
- right click on your project in the Solution Explorer, select Properties
- Go to Configuration Propertiesand then to Debugging
- Click on the arrow in the CommandField and click the EditButton
- In Editclik "Macros>>" You will see there the values of ProjectDir... etc..
- 在解决方案资源管理器中右键单击您的项目,选择属性
- 转到配置属性,然后转到调试
- 单击命令字段中的箭头,然后单击编辑按钮
- 在编辑中单击“宏>>”您将看到 ProjectDir... 等的值。
回答by Mona Jalal
回答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 '\'.
项目的目录(定义为驱动器+路径);包括尾部反斜杠“\”。


