Optional environment variables with vcproj/vsprops

谁说胖子不能爱 提交于 2019-12-05 17:19:06

I do not think this can be done at project level: the vc project file is not parsed for logical statements as far as I know (apart from the build events in which you can use batch file syntax but that's because they are ran as a batch file).

The only thing you can do is create a global environment variable that has the default variable. It will be overriden if the environment in which devenv is called also specifies it.

environment:

MYVSOUTDIR="c:/temp"

vcproj/vsprops:

OutputDirectory="$(MYVSOUTDIR)\_$(ConfigurationName)_$(PlatformName)"

override this in a batch file:

set MYVSOUTDIR="d:/mytemp"
devenv

hmm, apparently I do not know how to fromat XML here

 <PropertyGroup Condition=" '$(your_var)' == '' ">
  <your_var>default</your_var>
 </PropertyGroup>

I know it's technically outside the purview of my original question, but I've gone about solving this by writing an add-in that will detect if the environment variable is set and, if not, construct the variable's default value and store it. It's not the most elegant solution, but it works.

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