Previously, the way I would hook into a projects/solutions build was to edit the .csproj file to import a build file. It always annoyed me and isn’t immediately clear to people (or me after I come back to a project) how the targets are being injected.
I recently discovered that you can follow certain naming conventions to automagically get your targets imported into the build. Now, I know some people think automagic is even less transparent than explicitly defining something, however the naming is quite straightforward and obvious.
Add a targets file named; [after|before].<SolutionName>.sln.targets to the same directory as your solution file.
The after file is added after the project files and the before file is added before the project files.
This only works for solutions.
As an example
<Target Name="RunPostBuildScripts" AfterTargets="Build"> <!-- Do Stuff Here --> </Target> More Info Here