我正在定制一个.csproj项目,在主构建之前运行一些自定义任务.但是,我根本无法执行任务.
我取消注释文件中的<Target Name="BeforeBuild" />元素.csproj并添加了一个简单的Message任务,但是当我构建时,消息没有出现在我的输出中,所以看起来任务没有运行.所以这个片段不输出消息;
清单1:没有消息出现
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" Importance="normal" />
</Target>
Run Code Online (Sandbox Code Playgroud)
但是,如果我搞砸了一些属性,我可能会.csproj完全无法执行;
清单2:MSBuild配置错误
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" XXImportance="normal" />
</Target>
Run Code Online (Sandbox Code Playgroud)
注意XXImportance属性.我得到的构建错误是
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.
Run Code Online (Sandbox Code Playgroud)
这表明正在解析XML,Message已找到该类,并且该类正在反映可用属性.
为什么这个任务不会执行?
我正在使用3.5框架.
更新1:在@Martin的建议下,我试图在控制台上运行MSBuild,并得到了这个错误;
c:\path\to\my.csproj(74,11): error MSB4019: The imported …Run Code Online (Sandbox Code Playgroud)