Is there a way to make user specific pre/post build events in Visual Studio projects?

萝らか妹 提交于 2019-12-05 06:02:19

The short answer is no, not the way you want to do it :|

The slightly longer answer is sorta. You can in theory have specific build events triggered for individual users, but these would still be in the csproj file. You can run external events on builds and then allow these external events to run depending on what user is running them (as a script).

If this is for debug only I'd just insert them, do your build stuff and pull them out before uploading it to your version control system.

Micah Armantrout

Use an if statement and an enviroment variable (in double quotes if required)

if "$(Username)" == "MyUser"
  copy /y $(ProjectDir)memcached.$(ConfigurationName).config $(ProjectDir)memcached.config

You can utilize a custom build target that has a condition triggered by an environment variable. Then only set that variable on your machine.

Pre-/Post-build events are kept in the project file. VS provides no options.

You can introduce a custom (external) tool to perform such copying though and call it from menu, or macros and call it too.

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