Visual Studio 2008生成后事件-仅在重建上运行 [英] Visual Studio 2008 Post Build event -- only run on Rebuild

查看:121
本文介绍了Visual Studio 2008生成后事件-仅在重建上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2008中,我们运行一个后生成事件,该事件调用NANT,并依次创建我们的配置文件.

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

例如

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

有没有一种方法只能在ReBuild上运行?

Is there a way to run this only on ReBuild?

推荐答案

我认为您可以通过指定构建目标而不是使用构建事件来做到这一点.尝试创建AfterClean目标以删除生成的配置文件,并创建BeforeBuild目标以创建它们.确保为BeforeBuild目标设置了文件依赖关系,因此msbuild知道它仅在文件不存在时才运行该步骤.

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.

我实际上没有尝试过,但是我相信msbuild仅在目标文件不存在时才运行目标.重建时,将调用清理过程,并依次调用AfterClean目标.

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.

您可以在此处了解更多信息.使用构建目标代替事件的唯一真正缺点是,它们在VS UI中的任何位置都不可见-只有在检查项目文件时才能找到它们.

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.

可能存在涉及事件的更直接解决方案-请查看msbuild团队博客此处.

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

这篇关于Visual Studio 2008生成后事件-仅在重建上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆