Cannot change Target Framework on Several Projects From v4.0 to V4.5 or 4.5.1
Asked Answered
U

5

20

I have several projects in a large solution that won't convert to V4.5.1 (or even V4.5). Most did, but obviously I need to get all of them converted. The GUI in Visual Studio says that it did it and reloads the project, but if you go back into the properties it still says V4 and it won't compile because of dependencies that converted properly and are V4.5.1

I tried manually updating the .csproj files and it says 4.5.1 as the target framework, and I even updated the app.config/web.config to point to the right version, however Visual Studio's property page still says .NET 4 and is throwing compile errors because it can't access the ones that successfully updated to 4.5.1

What am I missing in the process to get these updated? I've tried VS.net 2012 and 2013 and both do the same thing.

Underwriter answered 23/1, 2014 at 18:46 Comment(6)
Which version of VS is your destination? You can't go higher than 4.5 in 2012. If you want 4.5.1 you'll need 2013. You probably already know this, but it wasn't clear (to me) in your question.Kalif
This makes little sense. Only the <TargetFrameworkVersion> property in the .csproj file matters to the compiler. Do make sure these are not actually IntelliSense errors or an outdated Resharper style add-in that doesn't know anything about later .NET versions.Tagalog
Tim: VS.net 2012 can target 4.5.1 if you install the developer deployment pack, however it doesn't work on Vs.net 2013 either. And even if you choose 4.5 it still won't update.Underwriter
Hans: I thought so too, but VS.net wont' compile the projects using the updated framework version either. I tried removing all of the nuget packages like Entity Framework to see if that mattered, but it didn't make any difference.Underwriter
I'm having this issue as well - in a solution that has many projects targeting 4.5, we have two that won't switch over. Investigating...Incommode
Hi, have any of you had any luck with this? I'm experiencing the same issue. There is a single WPF project that will not migrate to .NET 4.5. I have spent two full days on this now and made no real progress. Tried doing this in VS 2012 and VS2013. Adding new project to the same solution allows me to change target framework on that project, so I know the problem is project specific. I'm migrating from .NET 4.0 to 4.5.Donell
U
12

In hopes that this helps others:

In our case, the issue was that we were referencing a custom targets file that was created for the entire solution. even though the project was getting updated, the custom targets file was overriding it thus preventing the project from getting updated.

Updated the targets file to point to .net 4.5 and everything was fine.

Underwriter answered 15/7, 2014 at 20:58 Comment(5)
And it turned out that we had the same issue, just found it. Thanks for reporting the error. Visual Studio does not show the conflict gracefully, that's for sure.Incommode
Hi, I've been experiencing the same issue for two days now. How did you update the targets file to point to .net 4.5? I can set TargetFramework in the project file, but I don't know how to change the target file to point to .net 4.5Donell
If you go in there is a field "TargetFramework", just change it to 4.5 and save it without the project open.Underwriter
Hi, I've tried that, but when I open the project up, the target framework is set to .NET Framework 4.Donell
Check that there isn't an imported *.targets file in the csproj. It's almost always an imported targets file that's messing with it. (You have to load the .csproj raw, not load up the project in vs.net)Underwriter
E
2

For me, the solution was to remove all the extraneous <PropertyGroup> sections from the .csproject file - except the first one.

VS 2015 was setting the <TargetFramework> to 4.5.1 on only one of them (not the first one).

Expostulate answered 8/10, 2015 at 17:29 Comment(0)
D
1

After two days of suffering, I have created a new project, targeted .NET 4.5 and then manually copied all files from the existing project. Made sure new project compiles. Removed old project. Moved new project into the directory of the old project so that I can reverse merge into trunk. Job done.

Project I was upgrading was an old WPF project with thousands (no kidding) XAML files in a single project. It also had a release preview of MvvmLight (years old) and an older version of Prism along with a range of other libraries. All and all the project is a mess and somebody must have done something really stupid to make targeting .NET 4.5 this difficult.

Donell answered 17/3, 2015 at 9:31 Comment(0)
C
1

I had a similar issue. Turns out the DLLs were built for target framework 4.5.1, but the project I was working in was built for 4.5 only. There were some suppressed warning messages when I compiled. When I showed compile warnings, that was the hint that told me what was going on.

I recompiled the DLLs for framework 4.5, and then the DLLs copied automatically without needing additional references to the assemblies.

Contrapuntist answered 16/3, 2016 at 17:25 Comment(0)
S
0

In my case I was working with projects designed for SharePoint 2010. Apparently the project template restricts the .NET target framework version which can be selected.

As I was trying to compile a SharePoint 2016 server, once I got the beta templates downloaded for 2016, Visual Studio automatically prompted me to upgrade these projects when trying to open the solution again. Hope this helps someone.

Preview bits for SharePoint 2016 are available here: https://www.microsoft.com/en-us/download/details.aspx?id=49972

Stralka answered 27/6, 2016 at 21:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.