Visual Studio 2012 Post Build Events - Error Code 255

爱⌒轻易说出口 提交于 2019-12-05 09:33:22

You need to enable delayed expansion, using the SETLOCAL EnableDelayedExpansion command. Do it at the top of the post-build event. After that, you can access your variable by using not %VARIABLE_NAME%, but !VARIABLE_NAME! (use an exclamation symbol on either side of the variable name, not the percentage symbol which you would use in a regular batch file).

So, for example

SETLOCAL EnableDelayedExpansion
IF $(ConfigurationName) == Release (
    SET DESTINATION=$(ProjectDir)Output\Distribution
    echo My destination dir is !DESTINATION!
)

This will output something like

My destination dir is D:\Work\Projects\PBExample\Output\Distribution.
Matthew Lock

Since the Post-build event command line actually runs as a batch file you need to escape characters like % by doubling them to %%:

https://stackoverflow.com/a/13552702/74585

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