Visual Studio 2008 Post Build event — only run on Rebuild

余生颓废 提交于 2019-12-06 02:04:33

问题


In Visual Studio 2008 we run a post build event which calls NANT and in turn creates our config files.

e.g.

if $(SolutionDir) == . GOTO end
nant -buildfile:$(SolutionDir)default.build create..web.config

Is there a way to run this only on ReBuild?


回答1:


I think you can do this by specifying build targets rather than using build events. Try creating an AfterClean target to delete your generated config files, and a BeforeBuild target to create them. Make sure you set up the file dependency for the BeforeBuild target, so msbuild knows it should only run the step if the file isn't present.

I haven't actually tried this, but I beleive msbuild will only run the target if the target files don't exist. When you rebuild, the cleaning process will be invoked, and in turn your AfterClean target.

You can read more about build targets here. The only real downside to using build targets instead of events is that they are not visible anywhere in the VS UI - you will only find them if you inspect the project file.

There may be a more direct solution involving events - have look at the msbuild team blog here.



来源:https://stackoverflow.com/questions/2691847/visual-studio-2008-post-build-event-only-run-on-rebuild

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