To accomplish the targets before and after the solution, you must create two MSBuild project files named "after. <SolutionName> .sln.targets" and "before. <SolutionName> .sln.targets" in the same way as your solution.
To do this on all solutions, you will lose your custom solution level after the goal files to the path $ (MSBuildExtensionsPath) \ $ (MSBuildToolsVersion) \ SolutionFile \ ImportBefore \ or $ (MSBuildExtensionsPath) \ $ (MSBuildToolsVersion) \ SolutionFile \ ImportAfter. When these solutions are built, he will import all the project files into these folders, if they exist.
To verify this, open a command prompt and navigate to the folder containing the solution file. Enter "SET MSBuildEmitSolution = 1". Then run msbuild.exe <SolutionName>. You will see that msbuild saved the <SolutionName> .sln.metaproj and <SolutionName> .sln.metaproj.tmp metadata project files in the same way as your solution.
View the <Import /> declarations at the top and bottom of the file, and you will notice a conditional import that will allow you to declare specific decisions before and after goals or global specific decisions before and after goals.
Edit:
It seems like this only applies to the command line or command assembly, but not from Visual Studio.
I added this to my After.Solution.sln.targets file:
<Target Name="Banana" AfterTargets="Build"> <Message Text="*** BEGIN BANANA ***" Importance="high" /> <Message Text=" _ " Importance="high" /> <Message Text="//\ " Importance="high" /> <Message Text="V \ " Importance="high" /> <Message Text=" \ \_ " Importance="high" /> <Message Text=" \,'.`-. " Importance="high" /> <Message Text=" |\ `. `. " Importance="high" /> <Message Text=" ( \ `. `-. _,.-:\" Importance="high" /> <Message Text=" \ \ `. `-._ __..--' ,-';/" Importance="high" /> <Message Text=" \ `. `-. `-..___..---' _.--' ,'/ " Importance="high" /> <Message Text=" `. `. `-._ __..--' ,' / " Importance="high" /> <Message Text=" `. `-_ ``--..'' _.-' ,' " Importance="high" /> <Message Text=" `-_ `-.___ __,--' ,' " Importance="high" /> <Message Text=" `-.__ `----''' __.-' " Importance="high" /> <Message Text=" `--..____..--' " Importance="high" /> <Message Text="*** END BANANA ***" Importance="high" /> </Target>
From the command line: Bananas!
In the TFS assembly: Bananas!
Visual Studio: no bananas: (