I need a set of tasks that need to be executed exactly once for the entire solution. This will run tasks that will modify each project to run a separate set of tasks for each project. We had done this earlier using a separate project to the solution which had the solution level tasks, but we want to move away from that. Has anyone done this or does anyone have any suggestions on how to implement this?
+1
A:
Since Solution files are not in MSBuild format they are not easily extended or customized. If you want more control over the build process you would have to create a "driver" msbuild file which would replace your solution file. Inside this driver file you would build all the projects that you needed and perform some additional tasks. You would do this using the MSBuild task. Here is a sample showing how to build more than 1 project.
<Project ...>
<ItemGroup>
<Projects Include="proj01.csproj"/>
<Projects Include="proj02.csproj"/>
<Projects Include="proj03.csproj"/>
</ItemGroup>
<Target Name="BuildAll">
<MSBuild Projects="@(Projects)" BuildInParallel="true" />
</Target>
</Project>
So in your case you would just execute the tasks before you build the projects. Also note that I specified the value true for the BuildInParallel
indicating that MSBuild can try and build more than one project at once.
Sayed Ibrahim Hashimi
2010-03-16 16:16:50
This is an interesting idea. I believe this will also work if I want to perform some additional tasks before building the projects? (And those additional tasks will be modifying the projects themselves.)
Chandam
2010-03-18 13:03:53
Creating these build files is a very common scenario. A lot of people prefer writing these types of build files instead using the solution for production builds. In my case I only use solution files for Visual Studio, never for actual builds.
Sayed Ibrahim Hashimi
2010-03-18 13:39:47