问题描述
如何在项目生成后事件中使用系统环境变量,而不必编写和执行外部批处理文件?我认为这就像创建一个名为LHDLLDEPLOY
的新环境变量并在构建后事件文本框中编写以下内容一样简单:
copy $(TargetPath) %LHDLLDEPLOY%\$(TargetFileName) /Y
copy $(TargetName).pdb %LHDLLDEPLOY%\$(TargetName).pdb /Y
...但是a,不.构建输出显示它已将文件写入"%LHDLLDEPLOY%
"文件夹(两次为"1 file(s) copied
"),但是文件不在等价路径中,并且没有名为"LHDLLDEPLOY
"的新文件夹./p>
他们实际上去了哪里,我该如何正确地做到这一点?
(更新: Xavier 钉上了它.此外,他的变量格式$(LHDLLDEPLOY)
在我重新启动计算机以刷新环境变量后起作用.)
(更新2:原来我不必重新启动计算机.我只需要确保我a)关闭了环境变量列表窗口,b)关闭/重新启动了Visual Studio.)
您尝试使用$(LHDLLDEPLOY)代替%LHDLLDEPLOY%吗?
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 LHDLLDEPLOY
and writing the following in my post-build event textbox:
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
"
Where did they actually go, and how do I do this correctly?
(UPDATE: Xavier nailed it. Also, his variable format of $(LHDLLDEPLOY)
worked after I rebooted the machine to refresh the environment variables.)
(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.)
Did you try $(LHDLLDEPLOY) instead of %LHDLLDEPLOY%?
这篇关于如何在VS 2008生成后事件中使用系统环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!