MS-Build BeforeBuild not firing(MS-Build 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.
我取消了 .csproj
文件中的 <Target Name="BeforeBuild"/>
元素的注释并添加了一个简单的消息任务,但是当我构建时,消息没有出现在我的输出中,因此任务似乎没有运行.所以这个片段不输出消息;
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,已找到 Message
类,并且正在反映该类以获取可用属性.
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: 在 @Martin 的建议下,我尝试在控制台上运行 MSBuild,但出现此错误;
UPDATE 1: On @Martin's advice, I tried to run MSBuild on the console, and got this error;
c:path omy.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 行读取;
<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-Build BeforeBuild 未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MS-Build BeforeBuild 未触发
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01