Search code examples
c#.netvisual-studiovisual-studio-2015.net-2.0

Cannot target .Net 2.0 in Visual Studio 2015


I have a project that targets both .Net 2.0 and .Net 4.5. I built+published it successfully in Visual Studio 2013. The .Net configuration in the .csproj file still says

<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

Yet, when I open the project in VS 2015, it targets .Net 4.5.

I have 2.0 available in the Target Framework dropdown:

Target Framework Dropdown

when I click ".Net Framework 2.0" it gives me a popup saying

Are you sure?

Changing the target framework requires that the current project be closed and then reopened.
Any unsaved changes within the project will be automatically saved.

Changing Target Framework my require manual modification of project files in order to build.

Are you sure you want to change the Target Framework for this project?

When I click yes, the target framework goes back to 4.5 and nothing else happens.

  • I've tried reopening the project and VS, with no luck.
  • I've tried running the .Net 3.5 installer (which apparently includes 2.0), but it says I need to use "Turn Windows Features on/off"
    • I've ensured the .Net 3.5 Windows Feature is enabled.

And now I'm out of ideas. Has anyone else encountered this?

Running Windows 7.


Solution

  • As Hans Passant mentions in the comments, I apparently(?) edited the .csproj to use different frameworks for different configurations. I swear this didn't cause any issues in VS 2013.

    But in any case, I verified using ILSpy that the .dll being generated is .Net 2.0, even though the dropdown says 4.5. So I guess all's well that ends well?