Defining Project Paths in a Solution via Macro/Environment Variable

一笑奈何 提交于 2019-12-09 08:27:19

问题


Is there a way to define the project file path in a solution using a user macro/environment variable? I can't seem to do that.

Kind of like an environment variable is used to define the additional include directories in a C++ project, except I want to do the same for the location of a project file in a solution.

I've tried editing the solution in a text editor to change the path to start with %MyMacroName% or $(MyMacroName) but neither of them seems to parse just right. The project files can't be located when the solution is opened.


回答1:


In .sln file use syntax "%ENV_VAR%rest_of_the_path\test.csproj"

In .csproj file use syntax "$(ENV_VAR)rest_of_the_path\test.dll"

That works for me, ENV_VAR is custom environment variable defined for operating system like ENV_VAR = "C:\MyPath\"




回答2:


MSBuild allows you use to environment variables,

http://msdn.microsoft.com/en-US/library/ms171459(v=VS.80).aspx

So that you should be able to define environment variables as you wish, and then modify vCxproj files to make use of them.

I am not sure if that tip works for sln files, as sln files are not MSBuild scripts.



来源:https://stackoverflow.com/questions/10669000/defining-project-paths-in-a-solution-via-macro-environment-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!