Today I meet a similar problem and it reminds me about this thread. In Visual Studio, if we open the .csproj file, we see that they tell us to uncomment the two targets AfterBuild and BeforeBuild so as to execute them after and before the build of the current project accordingly.
My questions are: Where are these two targets called in Visual Studio? And how is it handled if the targets are not defined (be commented out) ?
Those targets are contained in a file named Microsoft.Common.targets
. This file is imported into your scripts via another import, Microsoft.CSharp.targets
(or similar for other languages). So they are always defined when the build starts. In your project files you can override those targets by re-declaring them after the <Import
statement for the file mentioned previously. If you declare them before the <Import
then your targets will be ignored because the empty ones in Microsoft.Common.targets
will be used.
For more info on extending the build process see my article Inside MSBuild or better yet my book Inside the Microsoft Build Engine!
In response to the previous commenter those targets are a part of the build process which builds your projects. They are captured in MSBuild files, and are neither a part of MSBuild nor Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With