VS2010:如何在构建后使用环境变量 [英] VS2010: How to use Environment Variables in Post-Build

查看:70
本文介绍了VS2010:如何在构建后使用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的PC上,我创建了一个名为 3DSMaxInstallDirectory

On my PC I have created a system environment variable called 3DSMaxInstallDirectory

在命令行中,如果我给

echo %3DSMaxInstallDirectory%Plugins\

我知道

D:\Program Files\Autodesk\3ds Max 2011\Plugins\

在Visual Studio中,我进入构建后"部分

In Visual Studio I enter into the Post-Build section

copy "$(TargetDir)$(TargetName).*" "$(3DSMaxInstallDirectory)Plugins\"

但是在构建时我得到了

Error   4   The command "copy "C:\Users\Sebastian\Documents\Visual Studio 2010\Projects\MaxBridge\MaxBridgeImporterPlugin\bin\Debug\MaxBridgePlugin.*" "Plugins\"
" exited with code 1.   MaxBridgeImporterPlugin

Google上的结果令人困惑,表明Visual Studio不支持EV,Visual Studio支持EV,Visual Studio需要%..%和Visual Studio需要$(..)的建议混合在一起-似乎都没有在我的计算机上工作.

The results on Google are a confusing mix of suggestions that Visual Studio doesn't support EVs, Visual Studio does support EVs, Visual Studio needs %..% and Visual Studio needs $(..) - and none of which seem to work on my computer.

在Visual Studio中使用我的环境变量的正确方法是什么?

(是的,目录存在,而我不想显式设置路径的原因是我正在准备共享此项目,下载后和构建之前,别人必须采取的每个步骤都是另一个障碍.)

(Yes, the directory exists, and the reason I don't want to set the path explicitly is I am preparing to share this project, and every step someone else has to take after downloading and before building is another barrier.)

推荐答案

这在项目的构建事件"的构建后"设置中对我有用.

This works for me in the Post-Build setting of the 'Build Events' of the project.

echo %CodeContractsInstallDir%
echo %DXSDK_DIR%
echo "%ONLYME%"

ONLYME是我的配置文件的User变量中的一个环境变量.

ONLYME is a environment var in the User variables of my profile.

其他是系统范围的变量.

The others are System wide vars.

如果我以管理员身份启动VS2010,则ONLYME仍然为空,systemvars仍具有预期的值.

ONLYME stays empty if I start VS2010 as administrator, the systemvars still have values as expected.

我正在使用V2010 SP1

I'm on V2010 SP1

这篇关于VS2010:如何在构建后使用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆