MSBuild BeforeBuild步骤 [英] MSBuild BeforeBuild Step

查看:637
本文介绍了MSBuild BeforeBuild步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天询问有关获得 AfterBuild 的工作,并且能够通过将它放置在项目部分: MSBuild AfterBuild步骤



我试过与不同的项目完全相同的事情。这是我的 BeforeBuild 代码:

 < Target Name =BeforeBuild > 
< Message Text =### HI ###Importance =High/>
< / Target>

我之前没有另一个目标名称=BeforeBuild code>在项目中,我把这放置在项目部分的最底部。 .vcxproj正在解析/加载到Visual Studio 2010中没有问题。我有我的MSBuild项目生成输出/日志verbocity设置为正常。



有没有别的,我没有想到会导致这不运行?

解决方案

目标不被调用,除非明确调用,是一个默认目标,被声明在一个目标的Depends或者声明自己的BeforeTargets或AfterTargets,并调用其中一个目标。



因此,如果你想在一个名为InitializeBuildStatus的目标之前调用一个目标,这样写:

 < Target Name =MyBeforeBuildBeforeTargets =InitializeBuildStatus> 
< Message Text =### HI ###Importance =High/>
< / Target>

如果InitializeBuildStatus目标运行,它将运行。 (您可以在Visual Studio或MSBuild运行中启用详细日志记录以帮助确定适当的BeforeTarget目标。)

明确调用BeforeBuild和AfterBuild目标由目标系统的一些微软的项目类型。这只提供有限的可扩展性。较新的(.NET 4.0)方式是BeforeTargets和AfterTargets。



请参阅目标构建订单


I asked yesterday about getting AfterBuild working and was able to get that working by placing it at the very bottom of the Project section: MSBuild AfterBuild Step

I have tried the exact same thing with a different project. This is my BeforeBuild code:

<Target Name="BeforeBuild">
    <Message Text="###HI###" Importance="High" />
</Target>

I don't have another before Target Name="BeforeBuild" in the project and I have this placed at the very bottom of the Project section. The .vcxproj is parsing/loading into Visual Studio 2010 without issue. I have my "MSBuild project build output/log verbocity" set to "Normal".

Is there something else I haven't thought of that would cause this not to run?

解决方案

A target is not called unless called explicitly, is a default target, is declared in DependsOn of a target that is called or declare its own BeforeTargets or AfterTargets and one of those targets is called.

So, if you want a target to be called before a target called "InitializeBuildStatus", you can write it like this:

<Target Name="MyBeforeBuild" BeforeTargets="InitializeBuildStatus">
    <Message Text="###HI###" Importance="High" />
</Target>

It'll run if the "InitializeBuildStatus" target runs. (You can enable verbose logging in Visual Studio or for an MSBuild run to help determine the appropriate BeforeTarget targets.)

The "BeforeBuild" and "AfterBuild" targets are called explicitly by the target system of some of Microsoft's project types. That offers only limited extensibility. The newer (.NET 4.0) way is BeforeTargets and AfterTargets.

See Target Build Order.

这篇关于MSBuild BeforeBuild步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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