When does Visual Studio call the target AfterBuild & BeforeBuild? And how is it handled when these goals are not defined?

Today I encounter a similar problem, and it reminds me of this topic. In Visual Studio, if we open the .csproj file, we see that they tell us to uncomment the two AfterBuild and BeforeBuild targets in order to execute them after and before building the current project, respectively.

My questions are: where are these two goals in Visual Studio? And how is this handled if goals are not defined (comment)?

+4
source share
1 answer

These goals are contained in a file called Microsoft.Common.targets . This file is imported into your scripts through another import, Microsoft.CSharp.targets (or similar for other languages). Therefore, they are always determined when assembly begins. In project files, you can override these goals by re-declaring them after the <Import statement for the previously mentioned file. If you declare them before <Import , then your goals will be ignored, because empty ones in Microsoft.Common.targets will be used.

For more information on expanding the build process, see my article Inside MSBuild, or better than my book Inside Microsoft Build Engine !

In response to a previous commenter, these goals are part of the build process that builds your projects. They are written to MSBuild files and are not part of MSBuild and Visual Studio.

+9
source

Source: https://habr.com/ru/post/1306439/


All Articles