MS-Build BeforeBuild not firing

戏子无情 提交于 2019-11-29 06:01:16

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

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

And set MSBUild verbosity to minimal or normal.

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

Had the same problem today and found the way to make it work.

The BeforeBuild target in your .csproj file is intended to be a redefinition of a target defined (and referenced) in the Microsoft.Common.targets file, which is imported by the Microsoft.CSharp.targets file, which in turn is imported by your .csproj.

Your problem is that the line in your .csproj that imports Microsoft.CSharp.targets is after your definition of the BeforeBuild target. Move the import line to above your BeforeBuild target and everything should work fine.

Hope that helps,

There is a feature in Visual Studio to allow you to debug MSBuild. You could try that. It is officially unsupported but useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!