MSBuild OutDir per project in solution

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" 

  <!-- Needed to import the assembly from the right location -->

 <!-- 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 -->


About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Tooling and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.