We use a dedicated project file for building our solution/projects. The automated build sometimes complains about failing unit tests due to incompatible assembly versions. By building every project to their own OutDir we solved the issue.
MSBuild tasks
Install the MSBuild tasks with the package manager console and add the .build folder it creates to source control.
install-package MSBuildTasks
Undo any changes to the project and package.config. The .build folder is all you’ll need.
Build project
Change the build project to get the projects in the solution using the MSBuild tasks.
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <!-- Needed to import the assembly from the right location --> <MSBuildCommunityTasksPath>$(MSBuildThisFileDirectory).build</MSBuildCommunityTasksPath> <BuildOutput>$(MSBuildThisFileDirectory)bin</BuildOutput> <Configuration>Release</Configuration> </PropertyGroup> <!-- Needs MSBuildCommunityTasksPath to be set --> <Import Project="$(MSBuildThisFileDirectory).build\MSBuild.Community.Tasks.Targets"/> <Target Name="Build" DependsOnTargets="GetProjectsFromSolution"> <!-- Build every project in the solution --> <MSBuild Projects="%(ProjectFiles.Fullpath)" <!-- OutDir specifies the location the assemblies end up --> Properties="Configuration=$(Configuration); OutDir=$(BuildOutput)\%(ProjectFiles.Filename)\" Targets="Build"/> </Target> </Project>
References
- msbuild SLN and still get separate project outputs? on stackoverflow
- MSBuild tasks on github