Basically, I'm trying to implement some preliminary and post-build events for the entire solution, and not just for individual projects. I saw this question here before, but did not address the same issue. I created two .targets
files named after.TestSolution.sln.targets
and before.TestSolution.sln.targets.
Inside each:
front
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="CreateFile" BeforeTargets="Build"> <Message Text="Creating a file" Importance="high" /> <Exec Command="C:\users\me\Desktop\CreateFiles.bat" /> </Target> </Project>
after
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="CopyFile" AfterTargets="Build"> <Message Text="Copying a File" Importance="high" /> <Exec Command="C:\users\me\Desktop\CopyFiles.bat" /> </Target> </Project>
These are just simple test batches to see if events work. Then I create the solution through MSBuild from the command line: this works completely. MSBuild executes the code inside the "before" before building the solution, and the same for the "after" after. HOWEVER, the problem is that I am going to build a solution from VS, the parties never start. So I'm not sure why that is. I am new to MSBuild tasks.
source share