Jeevan Jeevan - 11 months ago 55
C# Question

Visual studio 2015: TargetFramework does not change to 4.5.2 even if pick up from dropdown. Reverts to 4.5

I have seven projects in my solution, six of them are targeting .Net framework 4.5.2. The seventh one is referring the other projects and its targeting .Net framework 4.5. The reason it is like this is because few of the projects can be opened with another solution and they were upgraded.

When I build, I get an warning (actually Error window shows 0 errors / 0 warnings but status shows 'Build failed'. Output window shows many errors and warnings. Weird!) saying

"The primary reference project1.dll could not be resolved
because it was built against the ".NETFramework,Version=v4.5.2"
framework. This is a higher version than the currently targeted
framework ".NETFramework,Version=v4.5" (of Project7).

So, I went to Project7's project properties and changed the Target Framework from 4.5 to 4.5.2. I got an warning saying I am about to change the framework which requires closing and reopening of project. I click yes. It refreshes the project properties window. But then Target Framework is still 4.5.

I open the csproj in notepad i see the target framework is 4.5.2. App.config also has 4.5.2. I restarted visual studio and project properties window still shows 4.5.

I have VS2015 professional with update 2. My manager has the same with update 3 and he says is also seeing the same problem.

Why is it not getting updated properly in project properties window? If it really got updated, then why am I seeing the warning mentioned above?

Any pointers is appreciated. Thanks.

Answer Source

If you are importing a project file in csproj; make sure to remove the framework version tag in the imported project file.
Eg: If the parent project has import tag
<Import Project="test\ProjectBase.Files" />

Then in ProjectBase.Files remove the following tag