Visual Studio Post Build does not like my conditional

为君一笑 提交于 2019-12-23 18:22:56

问题


I have a post build conditional that looks like this:

if $(ConfigurationName)==Release
(
    echo Update $(TargetName) to be non conflicting
    "$(SolutionDir)ILMerge\RummageTypeRenamer.exe" -f XamlGeneratedNamespace.GeneratedInternalTypeHelper -t XamlGeneratedNamespace.GeneratedInternalTypeHelper$(TargetName) $(TargetName).dll
    del $(TargetName).dll
    ren $(TargetName).Runmage.dll $(TargetName).dll
)

This runs fine if I take off the condition and the parens. But if I run it as is, I get the error:

The syntax of the command is incorrect.

The whole statement then prints out, and the conditional looks good:

if Release==Release

Why doesn't Visual Studio like my conditional?


回答1:


found the solution here: How to run Visual Studio post-build events for debug build only (see this comment: I've found that the entire command needs to be on one line or you'll get "exited with code 255" )

So your post build should look like:

    if $(ConfigurationName)==Release goto _release

    goto _exit

    :_release

    echo Update $(TargetName) to be non conflicting
    "$(SolutionDir)ILMerge\RummageTypeRenamer.exe" -f XamlGeneratedNamespace.GeneratedInternalTypeHelper -t XamlGeneratedNamespace.GeneratedInternalTypeHelper$(TargetName) $(TargetName).dll
    del $(TargetName).dll
    ren $(TargetName).Runmage.dll $(TargetName).dll

    :_exit



回答2:


Try the K&R style parens:

if $(ConfigurationName)==Release (
    echo Update $(TargetName) to be non conflicting
    ...
)


来源:https://stackoverflow.com/questions/19436532/visual-studio-post-build-does-not-like-my-conditional

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