visual-studio 如何在 VS 2008 Post-Build 事件中使用系统环境变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/128634/
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 to use system environment variables in VS 2008 Post-Build events?
提问by Scott Fletcher
How do I use system environment variables in my project post-build events without having to write and execute an external batch file? I thought that it would be as easy as creating a new environment variable named LHDLLDEPLOYand writing the following in my post-build event textbox:
如何在我的项目构建后事件中使用系统环境变量而无需编写和执行外部批处理文件?我认为这就像创建一个名为的新环境变量LHDLLDEPLOY并在我的构建后事件文本框中写入以下内容一样简单:
copy $(TargetPath) %LHDLLDEPLOY%$(TargetFileName) /Y
copy $(TargetName).pdb %LHDLLDEPLOY%$(TargetName).pdb /Y
...but alas, no. The build output shows that it wrote the files to the "%LHDLLDEPLOY%" folder (as "1 file(s) copied" twice), but the files are not in the equated path and there is not a new folder called "LHDLLDEPLOY"
......但唉,没有。构建输出显示,它的文件写的“ %LHDLLDEPLOY%”文件夹(如“ 1 file(s) copied”两次),但这些文件不在等同路径并没有一个名为“新建文件夹LHDLLDEPLOY”
Where did they actually go, and how do I do this correctly?
他们实际上去了哪里,我该如何正确地做到这一点?
(UPDATE: Xaviernailed it. Also, his variable format of $(LHDLLDEPLOY)worked after I rebooted the machine to refresh the environment variables.)
(更新:Xavier搞定了。另外,$(LHDLLDEPLOY)在我重新启动机器以刷新环境变量后,他的变量格式有效。)
(UPDATE 2: Turns out that I did not have to reboot my machine. I just needed to make sure that I a) closed the Environment Variables list window, and b) closed/relaunched Visual Studio.)
(更新 2:事实证明我不必重新启动我的机器。我只需要确保我 a)关闭了环境变量列表窗口,b)关闭/重新启动了 Visual Studio。)
回答by Xavier Nodet
Did you try $(LHDLLDEPLOY) instead of %LHDLLDEPLOY%?
您是否尝试过 $(LHDLLDEPLOY) 而不是 %LHDLLDEPLOY%?

