获取 vcproj 文件中 $(ProjectDir)、$(SolutionDir) 的值
是否可以在 Visual Studio 之外以编程方式获取 $(ProjectDir)
或 $(SolutionDir)
的值?我的情况是我需要将 vcproj 文件作为文本文件读取并获取其属性(如输出目录等)。问题是某些属性包含环境变量(如 $(SolutionDir) 等)。
Is it possible to get the value of $(ProjectDir)
or $(SolutionDir)
programatically outside Visual Studio? My scenario is I need to read a vcproj file as a text file and get its properties like the outputdirectory etc.. problem is some properties contain environment variables like $(SolutionDir) and the like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您发现仅查看 .vcproj 文件是不够的。您还需要了解 .sln 文件。在解决这个问题之前,你有点陷入困境。当 Visual Studio 加载 .vcproj 文件并且找不到匹配的 .sln 时,它始终会创建 .sln 文件。也许你也想这样做。
Well, you found out that looking at the .vcproj file isn't enough. You need to know the .sln file as well. You're kinda stuck until you resolve this. Visual Studio will always create a .sln file when it loads a .vcproj file and cannot find a matching .sln. Maybe you want to do that too.
您实际上可以显示 Visual Studio 内部定义和使用的任何变量的值(以下步骤至少适用于 VS 2022),例如 $(SolutionDir) 或 $(WindowsSDK_IncludePath):
$(WindowsSDK_IncludePath)
$(ProjectDir)
C:\Program Files (x86)\Windows Kits...;C:\Program Files (x86)\ 等
<您的解决方案/项目文件夹>
You can actually display the value of any variable defined and used internally by Visual Studio (steps below apply at least for VS 2022), like $(SolutionDir) or $(WindowsSDK_IncludePath):
$(WindowsSDK_IncludePath)
$(ProjectDir)
C:\Program Files (x86)\Windows Kits...;C:\Program Files (x86)\ etc.
<your solution/project folder>