Visual Studio Can't Target .NET Framework 4.8
Asked Answered
F

12

74

I'm having some issues creating a project that targets .NET Framework 4.8. I am using Visual Studio 2019, upgraded to version 16.2.5. I have also installed the .NET Framework 4.8 Developer Pack. From the Visual Studio Installer, I don't see any option for enabling 4.8 development tools similar to 4.7.

Frederic answered 18/9, 2019 at 20:12 Comment(0)
F
32

This Visual Studio thread had all the answers I was looking for. The .NET Framework 4.8 Developer Pack includes both the SDK and Targeting Pack. After installing this and restarting Visual Studio, I can now see .NET Framework 4.8 as a targeting option for Visual Studio projects. You should not need to do any Visual Studio Installer steps.

Also mentioned in the above thread, .NET Framework 4.8 will be included in the Visual Studio installation process as of 16.3 (currently listed under 16.3 Preview 2).

Frederic answered 18/9, 2019 at 21:25 Comment(7)
I exited/re-opened VS and didn't see it. The link in this answer for Visual Studio thread isn't workingWaddle
@Michele, links are still working for me, you sure?Frederic
We can't reach the Visual Studio thread link from our company. But that's great that you can reach it. I wound up fixing the issue by re-creating the project, and searching templates for .net framework, and then transferred my classes to that. Thanks!Waddle
Sorry, but After installing this and restarting Visual Studio, I can NOT see .NET Framework 4.8Scruple
I installed it with VS2019 (v16.11.8) and I also can't see it. Doesn't work. I can only access Core and 5.Draggle
Just make sure that you installed the DEVELOPER PACK dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/…Toothsome
this doesn't work for meAron
D
79

Just had a similar issue with Visual Studio 2019 Community Edition: only .Net Core versions were shown.

I edited the .csproj file manually. I changed the line with the TargetFramework property to

<TargetFramework>net48</TargetFramework>

Oddly, now all other versions show up also.

Divided answered 28/10, 2019 at 12:3 Comment(15)
This looks like a bug. I followed all the other suggestions (VS 16.7.2 Community Edition, 4.8 Development Pack and Targeting Pack, and rebooting), but this fixed it.Macfadyn
Not all projects' .csproj files seem to hold <TargetFramework>. One of my projects just has <TargetFrameworkVersion>.Phenacaine
Also? I have now only .Net Framework and no .Net Core versions.. All these issues are dirty tricks of Microsoft to compel developer to use .Net Core. :(Layout
VS Professional 2019 16.9.1 and this solution worksJubilation
Just upgraded VS Community to 16.9.4, installed all other devel packs and I still couldn't choose anything other than .NET5.0. After editing the .csproj manually, suddenly all the "old" frameworks are there, but 5.0 has disappeared ... Weird.Boroughenglish
That did it for me too. Thanks !Loom
Bug still in 16.10.2 Additional note: I had to reload that project to refresh the value.Aufmann
Such a nasty bug that still existsSackbut
With 16.11 the workaround changing the .csproj file does not work. The selection list does not change and the desired framework (4.8) is not shown. The solution is to chose a different template type (not the ".NET Standard or .NET Core" but instead a "(.NET Framework)" named template) as @Kenneth Zhang points out in his answer. The template types appear to be mutually exclusive.Apex
VS2019 had the bug after our domain server went up in smoke. Installing VS 2022 did not do the trick. Uninstalling/reinstalling of 4.8 framework did not work. This worked instantly! Also showing all the other 4.x frameworks I have installed.Provolone
This is not a bug. If you create a .NET Framework project, only .NET Framework versions show for selection. Same for .NET Core/5/6. Same for .NET Standard. As you saw you can manually override this by editing the proj file directly.Rolandorolandson
Still works in VS 2022Astute
this is the only solution that works. this is a microsoft bug yet again. i think they changed naming from netxy to netx.y. once i put net48 in, all the version below 5.0 show up, but 5.0 and 6.0 now don't show up. they probably replaced a developer at microsoft :)Aron
I think it is deliberate not a bug: they want to push .net core and done two different project styles for any (most?) project types: the upper one is for .net core and waaaaay down there is the one targeting .net framework. I honestly did not even know there was a difference other than version numbers going up..Provolone
Worked for me in VS2022 - pretty amazed that this is still a thing.Frustration
V
46

Just thought I'll post my issues as I stumbled across this too with VS2019 Winforms project, and couldn't target anything apart from .Net 5 and Core 3.1. Turns out there're 2 types of Winforms, Winforms App and Winforms App (.Net Framework). The former won't be able to target the other .net framework. The latter is able to. Duh! Simple stuffs that aren't obvious.

Vince answered 26/1, 2021 at 12:33 Comment(2)
Thank you @Kenneth for this hint. This distiction holds for many template types. The text description often mentions ".NET Standard or .NET Core" (eg. Core 3.1 ... .NET 5.0) which obviously excludes ".NET Framework" (4 ... 4.8).Apex
Yes! This is also the solution for my VS2022 problem with a library project (dll). I chose the on top item library (.net or .net standard) and now I recreated and gone down the list finding library (.net framework) and its all there.Provolone
N
44

None of the solutions above fixed my issues but the one by Oak_3260548 Pointed me in the right direction.

In Visual Studio Installer, that can be accessed by clicking on "Tools / Get Tools and features" in the top menu, I selected the "Individual Component" tab and checked ".Net Framework 4.8 Targeting pack". That fixed it for me.enter image description here

Normandnormandy answered 2/12, 2021 at 11:18 Comment(6)
tried this. still doesn't work for me.Aron
With my Visual Studio 2022, I was able to select .NET Framework 4.8 as a target for a project, but not 4.8.1; but once I read this, and selected Tools/Get Tools and Features, and then scrolled the right pane down to the bottom and selected ".NET Framework 4.8.1 development tools" and updated the installation, 4.8.1 appeared in the project properties "Target framework" pulldown.Achromatic
It was already checked for me.Loma
I have .Net 4.8 installed, but still cannot select it in project propertiesBorg
I already have that checked, but still cant add .Net4.8 projectsBarracoon
still not working for me alsoCalcariferous
F
32

This Visual Studio thread had all the answers I was looking for. The .NET Framework 4.8 Developer Pack includes both the SDK and Targeting Pack. After installing this and restarting Visual Studio, I can now see .NET Framework 4.8 as a targeting option for Visual Studio projects. You should not need to do any Visual Studio Installer steps.

Also mentioned in the above thread, .NET Framework 4.8 will be included in the Visual Studio installation process as of 16.3 (currently listed under 16.3 Preview 2).

Frederic answered 18/9, 2019 at 21:25 Comment(7)
I exited/re-opened VS and didn't see it. The link in this answer for Visual Studio thread isn't workingWaddle
@Michele, links are still working for me, you sure?Frederic
We can't reach the Visual Studio thread link from our company. But that's great that you can reach it. I wound up fixing the issue by re-creating the project, and searching templates for .net framework, and then transferred my classes to that. Thanks!Waddle
Sorry, but After installing this and restarting Visual Studio, I can NOT see .NET Framework 4.8Scruple
I installed it with VS2019 (v16.11.8) and I also can't see it. Doesn't work. I can only access Core and 5.Draggle
Just make sure that you installed the DEVELOPER PACK dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/…Toothsome
this doesn't work for meAron
S
18

For anybody having this issue in VS 2019 Community edition. The problem in my case was confusion over which template to select. Templates for .NET Framework are in parenthesis and lower in the list (not showing at all in my case until I clicked the "clear" link next to the search box).

Examples:

Console App (.NET Framework) ASP.NET Web Application (.NET Framework) Class Library (.NET Framework) etc

Splenomegaly answered 9/7, 2021 at 2:19 Comment(3)
I suspect this is the problem some people above are having, I was expecting to choose the Class Library project and select .NET Framework 4.8 as the Target Framework. I wasn't expecting there to be a whole new set of project typesLeslileslie
This solved it for me. I now have a lot more options for projects. Microsoft does such stupid things!Eggers
This is the only answer that helped me. I have no idea why there is not a much clearer differentiation than this. Even filtering to 'Windows' in the platform dropdown in the project creation splash screen doesn't put .NET Framework projects at the top. This is really misleading as even the non-Framework WPF project has the tags 'C#', 'Windows' and 'Desktop' and sits HIGHER in the search results - as if the other ones will all have cross-platform capabilities even though this isn't the case. Thanks for this answer!Trotter
W
6

I installed framework 4.8 through VS under target frameworks. It wasn't selectable there, under project properties as I would expect.

I wound up having to re-create my VS project. For template, I found framework 4.8 through searching templates in project creation using framework c# console search params. I then copied my files over to the new project folder, and added them as existing items through the solution tool.

Waddle answered 2/2, 2021 at 17:51 Comment(0)
B
2

The solution for was was to add "Class Library (.Net Framework)" project to the solution, not "Class Library" which uses .Net Core.

Barracoon answered 13/6 at 10:31 Comment(0)
J
1

Even with lower Visual studio (mine is 15.2 under Win 2008 R2), you can do it!

  1. Install both Net Framework 4.8 Runtime AND Developper Pack
  2. Reboot the server
  3. Open your existing project and in the project properties, switch the framework to 4.8

That's it!

Jun answered 9/9, 2022 at 11:16 Comment(0)
C
0

I have found a solution: If I want Visual Studio Community 2019 to target .NET 4.8, I can create some simple projects by using Visual Studio Express 2013. In the Project settings I change the required .NET (up to 4.8) and save. After that, you can open that project with Visual Studio Community 2019 and you will see in the Project settings all .NET target options up to 4.8.

However, if you want to play with .NET Core 3.1 and .NET 5.0, you have to create a new project from within Visual Studio Community 2019.

Caliper answered 8/7, 2021 at 7:36 Comment(0)
O
0

No solution above solved my problem. The note in https://learn.microsoft.com/en-us/visualstudio/ide/step-1-create-a-windows-forms-application-project?view=vs-2019 point 2 note helped:

Note

If you don't see the Windows Forms App (.NET Framework) template, you can install it from the Create a new project window. In the Not finding what you're looking for? message, choose the Install more tools and features link.

The 'Install more tools and features' link from the 'Not finding what you're looking for' message in the 'Create new project' window

enter image description here

Next, in the Visual Studio Installer, choose the .NET desktop development workload.

enter image description here

After that, choose the Modify button in the Visual Studio Installer. You might be prompted to save your work; if so, do so. Next, choose Continue to install the workload.

Although I always check this when installing VS it was missing. And the tepmlates were missing even though I had the correct trageting packs installed.

Otherworld answered 30/11, 2021 at 12:31 Comment(1)
Chimps abound ..Martino
B
0

C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets

<!--
<GetReferenceAssemblyPaths
    Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
    TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
    RootPath="$(TargetFrameworkRootPath)"
    TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
    BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
    >
  <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
  <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
  <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
-->
Borak answered 14/2, 2022 at 9:38 Comment(1)
On newer 16.9, this is the only thing that worked. It did disable new .net5/.net core but I need to generally target 4.8 anywaysWhisper
A
0

1. Choose WPF APP (.NET Fromework) with XMAL

2. Select .NET 4.8

On Visual Studio 2022, I choose the WPF APP (.NET Fromework) with XMAL can support .NET Framework

Annalist answered 20/6, 2022 at 6:9 Comment(1)
By "Fromework" you mean "Framework" and by "XMAL" you mean "XAML" Someone that doesn't know might be slightly confused since there's no XMAL.Troublous

© 2022 - 2024 — McMap. All rights reserved.