Disclaimer: I don’t recommend a solution that contains projects targeting different versions of the .NET framework. However there are legitimate cases (e.g. inherited code), that demand solutions rather than a rewrite. You may decide to use a later version of the .NET framework than some of the existing code. If you mix these projects in the same solution and use the same nuget packages in different projects, you will get the following error.

The type or namespace name could not be found (are you missing a using directive or an assembly reference?)

MSBuild builds your solution in an order that determines dependencies but leaves the rest to chance. When nuget package references are resolved, they include the .NET version. By default MSBuild builds the solution into a single output directory. This means that if project A references package X and targets .NET 4.0 and project B references package X and targets .NET 4.5 then the last one to be built will overwrite the previous one’s package X dll. This will cause the build to fail.

But fear not, there is a solution.

Update the Output Location

  1. Edit the build definition
  2. Navigate to 2. Build
  3. Change 4. Output Location from to AsConfigured

Yay! Our build works again, but our unit tests won’t be run as part of the build.


Update our Test Run Settings

  1. Edit the build definition
  2. Navigate to 3. Test
  3. Go to 1. Automated Tests
  4. Expand 1. Test Source
  5. Click the ellipse on Run Settings
  6. Add ..\src\*\bin\*\*test*.dll to the default Test assembly file specification which is **\*test*.dll;**\*test*.appx


This important step instructs msbuild to look for unit tests in the source directories bin folders in addition to the standard single bin for the solution.

Now your tests will actually get run as part of your build.



  1. StackOverflow: Using AsConfigured and still be able to get UnitTest results in TFS
  2. Override the TFS Team Build OutDir property in TFS 2013

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

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

Twitter picture

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

Facebook photo

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


Connecting to %s