Visual Studio 17.4.5 no older net core targeting

Frank Isaac Soto Martínez 0 Reputation points
2023-02-28T03:04:32.7966667+00:00

Description

I cannot see older net core sdk in projects template (below .net core 2.1).

Configuration

.Net core environment path order:

221389818-2ae6ffec-e5fa-48b2-a77c-ecdfb2d2561d

Installed SDKs (same for x86):

221389875-2e2f9355-5551-4f7b-9f2a-0fd4af715611

Aviable versions in VS:

221389909-47f157aa-4aef-4fa0-9cf2-ff8fb7de0619

Question

It´s there any approach similar to making aviable .Net Framework 4 and 4.5 for VS2022, or it´s necessary a VSIX?

VS info

Microsoft Visual Studio Enterprise 2022

Versión 17.4.5

VisualStudio.17.Release/17.4.5+33403.182

Microsoft .NET Framework

Versión 4.8.09032

Versión instalada: Enterprise

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,628 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2023-02-28T07:37:55.0366667+00:00

    Hello Horus,

    Welcome to Microsoft Q&A forum and thank you for sharing us screenshots to check.

    For your description:

    I cannot see older net core sdk in projects template (below .net core 2.1).

    I notice that you are using Visual Studio 2022 Enterprise version 17.4.5, so it’s true, Visual Studio 2022 doesn’t support older .NET Core(below .NET Core 2.1). This document: Visual Studio 2022 Support for .NET Development has listed the supported .NET implementations:

    Visual Studio 2022 supports the following .NET implementations:

    .NET Framework versions 4.8.1, 4.8, 4.7.2, 4.7.1, 4.7, and 4.6.2

    .NET Core 7.0, 6.0, 5.0, 3.1, 3.0, 2.2, and 2.1.

    For your question:

    Is there any approach similar to making available .Net Framework 4 and 4.5 for VS 2022, or it’s necessary a VSIX.

    Like what the above document says, and .NET Framework 4.0 and .NET Framework 4.5 are not listed there.

    But perhaps you can try a workaround(before removing/copying files, please back up the related folders/files just in case):

    Download the Microsoft.NETFramework.ReferenceAssemblies.net45 NuGet package to a clean folder, open it as zip(or edit the file extension to .zip), navigate to its sub-folder(build\.NETFramework\v4.5), copy all of the files/folders to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 folder(you can skip the same files when the process stops on copying and pasting the files). You can try the similar steps for using .NET Framework 4.0.

    After performing above operations, please restart VS, and you can either change the project target framework to .NET Framework 4.5 or target to .NET Framework 4.5 when you are creating a new project in VS 2022.

    Besides, some old version of .NET Core and .NET Framework are end of life. This document: Servicing - End of life (EOL) has mentioned that:  

    Your use of out-of-support .NET versions may put your applications, application data, and computing environment at risk. You are strongly recommended to not use out-of-support software.

    So I may suggest you try to use a higher version of .NET Framework/.NET/.NET Core or try to update your project(s) to target a higher version of .NET Framework/.NET/.NET Core.

    Feel free to contact us, have a nice day.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Frank Isaac Soto Martínez 0 Reputation points
    2023-03-05T06:46:25.1133333+00:00

    The workaround is based on THOMAS LEVESQUE's .NET Framework approach (https://thomaslevesque.com/2021/11/12/building-a-project-that-target-net-45-in-visual-studio-2022/).
    As older .NET Frameworks SDKs are missing from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework, the same occurs with older .NET Core Templates.

    First I must explain the differences between the two approaches. For the .NET Framework it becomes very difficult to obtain the SDKs for each version below 4.5.1, so it is almost mandatory to extract the libraries from the nuget packages of the series: Microsoft.NETFramework.ReferenceAssemblies.net(ver), to then extract (as compressed files) the contents of build.NETFramework\v(ver)\ to the local system folder.

    But with .NET Core the scenario is somewhat simpler: It's easy to get the SDKs for .NET Core from https://github.com/dotnet/core/tree/main/release-notes/download-archives and install them on our OS without problems. And here comes the problem: Visual Studio 17 looks for the templates for project platform initialization in a folder (C:\Program Files (platform)\dotnet\templates) that does not contain templates from versions prior to .NET Core 3.0. However, these older versions have their own templates inside their respective folders: C:\Program Files (platform)\dotnet\sdk(ver)\Templates.

    So, we just have to copy the content of the templates folder (C:\Program Files (platform)\dotnet\sdk(ver)\Templates), to a subdirectory named with the name of the .NET Core version in the global templates folder (C:\Program Files (platform)\dotnet\templates(ver)).

    And that's how we're able to build software for .NET Framework versions from 2.0 to 4.8.x (I haven't found a compatible SDK for 1.0) and .NET Core + .NET from 1.0 to 7.x, keeping customers comfortable in their environments, and us as developers with a single version of Visual Studio.

    Sin título

    Sin título2

    0 comments No comments