build events for debug build only

How can I limit my post-build events to running only for one type of build? I'm using the events to copy DLLs to a local IIS virtual directory but I don't want this happening on the build server in release mode.


Pre- and Post-Build Events run as a batch script. You can do a conditional statement on $(ConfigurationName) .

For instance

if $(ConfigurationName) == Debug xcopy something somewhere

FYI, you do not need to use goto. the shell IF command can be used with round brackets:

if $(ConfigurationName) == Debug (
  copy "$(TargetDir)myapp.dll" "c:deliverybin" /y
  copy "$(TargetDir)myapp.dll.config" "c:deliverybin" /y
) ELSE (
  echo "why, Microsoft, why".
)

Add your post build event like normal. Then save you project, open it in Notepad (or your favorite editor) and add condition to the PostBuildEvent property group. Here's an example:

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <PostBuildEvent>start gpedit</PostBuildEvent>
</PropertyGroup>
链接地址: http://www.djcxy.com/p/18392.html

上一篇: 在Visual Studio中使用Git

下一篇: 仅为调试构建构建事件