MS-构建BeforeBuild不点火 [英] MS-Build BeforeBuild not firing

查看:275
本文介绍了MS-构建BeforeBuild不点火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定制 .csproj的项目的主构建之前运行一些自定义任务。但是,我不能让这些任务在所有执行。

I'm customising a .csproj project to run some custom tasks before the main build. However, I can't get the tasks to execute at all.

我注释掉了<目标名称=BeforeBuild/> .csproj的文件,并添加了一个简单的信息的任务,但是当我建立,该消息不会出现在我的输出,这样看来的任务没有运行。所以这个片段不输出信息;

I uncommented the <Target Name="BeforeBuild" /> element in the .csproj file and added a simple Message task, but when I build, the message doesn't appear in my output, so it seems the task isn't running. So this fragment does not output the message;

清单1:没有消息显示

<Target Name="BeforeBuild">
    <Message Text="About to build ORM layer" Importance="normal" />
</Target>



不过,如果我有一些属性的螺丝,我可以得到 .csproj的来未能在所有执行;

However, if I screw with some of the attributes, I can get the .csproj to fail to execute at all;

清单2:一个MSBuild配置错误

<Target Name="BeforeBuild">
    <Message Text="About to build ORM layer" XXImportance="normal" />
</Target>

请注意在 XXImportance 属性。生成错误我得到的是

Note the XXImportance attribute. The build error I get is

My.csproj(83,46): error MSB4064: The "XXImportance" parameter is not supported by the "Message" task. Verify the parameter exists on the task, and it is a settable public instance property.

这表明XML被解析,即消息类已发现,那类被反映在了可用的属性。

This suggests that the XML is being parsed, that the Message class has been found, and that the class is being reflected over for the available properties.

为什么任务没有执行?

我使用的是3.5框架。

I'm using the 3.5 framework.

更新1:在@马丁的建议,我试图在控制台上运行的MSBuild,并得到这个错误;

UPDATE 1: On @Martin's advice, I tried to run MSBuild on the console, and got this error;

c:\path\to\my.csproj(74,11): error MSB4019: The imported
project "C:\Microsoft.CSharp.targets" was not found. Confirm
that the path in the <Import> declaration is correct, and that
the file exists on disk.



74行显示;

Line 74 reads;

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />



更新2:我在编译VS2008,它使用C #3的编译器,但我编译该项目是一个框架2.0的项目。当从命令行运行(见更新1)构建似乎失败,因为有一个混乱,指定了 Microsoft.CSharp.targets 文件在哪里。

UPDATE 2: I'm compiling in VS2008, which uses the C#3 compiler, but the project I'm compiling is a framework 2.0 project. When run from the command line (see UPDATE 1) the build seems to fail because there is a confusion as to where the Microsoft.CSharp.targets file is specified.

推荐答案

该事件被触发,但您可能需要更改VS设置:

The event is firing, but you might need to change your settings in VS:

工具 - >选项 - >项目和
解决方案 - >生成和运行:

Tools->Options->Projects and Solutions->Build and Run:

和冗长的MSBuild设置为最小或正常。

And set MSBUild verbosity to minimal or normal.

此外,如果您编译通过控制台的MSBuild,你会看到消息,而不必更改上面的设置。

Also, if you compile through msbuild in the console you will see the message without having to change the above settings.

这篇关于MS-构建BeforeBuild不点火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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