Target Multiple Frameworks with MSBuild in csproj

Keywords: MSBuild, csproj, target multiple .net framework, visual studio, C#
Publish Date: 5/4/2014
Description: Target multiple .net frameworks with MSBuild in csproj

From 0 to 15 MPH with MSBuild.

Problem Scope:

For complicated and boring reasons I needed to target multiple .net frameworks that would continuously integrate with an existing build environment. This meant modifying my .csproj to target more than just my currently chosen framework. This does NOT cover using compiler directives to use features not available in all chosen frameworks.

!!Warning!! If you are really looking to do this you should definitely stop and answer the question Why. I'm not entirely sure that I'm doing it for the right reasons :).


Step 1: Google

Step 2: Stackoverflow


This post was the front runner but I wish somebody had posted an actual project to play with since it took me so long to understand what was happening.

With the help of my work buddies I think I understand enough to travel at about 15mph down the MSBuild super highway of secret variables.

Here is a working VS2013 example with a console app.


My logging comments tell me that I have no idea what order this stuff is running. Comments?

Comments (3):

Name: ozbob
Comment Date: 2/17/2017
I didn't find this worked for me. I combined this and

Name: ozbob
Comment Date: 2/21/2017
found an article supporting a similar but better approach:

Name: Allan
Comment Date: 2/21/2017
Cool, thanks for the info.

Leave a Comment:

    Captcha Challenge