Srikanth Reddy
Srikanth Reddy

Reputation: 147

Target Framework not showing older .Net versions in Visual Studio 2022

I installed Visual Studio 2022 on my PC. When I select the template "ASP.NET Core Web API" and try to choose the target framework, the dropdown is showing only the current framework .NET 6.0 (Long Term Support).

Why it is not showing the older versions?

I had planned to work on a .NET 5 version.

Missing older framework versions image

Upvotes: 9

Views: 7428

Answers (2)

Nyerguds
Nyerguds

Reputation: 5629

I did have the older .Net versions installed, and it still only showed 5.0 and 6.0, so the answer didn't help me. In the end, the culprit seemed to be the newer .csproj format; older projects I opened worked fine, and showed the versions from 2.0 to 4.8. Despite VS2022 having no issue with opening these solutions, I have yet to find a way to let it create them.

The old format starts like this:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0">

The new one, however, doesn't have an xml header or namespace definition. It starts like this:

<Project Sdk="Microsoft.NET.Sdk">

Bizarrely, this new type of project file doesn't even seem to contain a list of files included in the project.

Just replacing the header doesn't work, though; the new format is too different, and the old format expects a lot of things to be auto-generated in the .csproj file concerning build type and targeted CPU.

In the end, the easiest solution was just to make a copy of an older project, manually generate a GUID for the project and plug that into the .csproj and .sln file, and then clean out the files and start from that.

Upvotes: 2

gruby
gruby

Reputation: 116

Open Visual Studio Installer, click Modify and check if you installed older versions of .NET

Upvotes: 9

Related Questions