Select which version of .NET to use - .NET (2023)

  • Article
  • 7 minutes to read

This article explains the guidelines that the runtime, SDK, and .NET tools use to select versions. These guidelines provide a balance between running applications on the specified versions and making it easier for developers and end users to update their computers. These policies allow:

  • Easy and efficient .NET deployment, including security and reliability updates.
  • Regardless of the target runtime, use the latest tools and commands.

Version selection takes place:

  • When running an SDK commandthe SDK uses the latest installed version.
  • When creating an assemblyTarget framework monikers define compile-time APIs.
  • When running a .NET applicationFurther development of target framework dependent applications.
  • If you publish a standalone application,Standalone deployments include the selected term.

The remainder of this document examines these four scenarios.

SDK uses the latest installed version

SDK commands includePunktnetz NovojRun dotnet. The .NET CLI must choose one SDK version at a timeNet pointDomain. It uses the latest SDK installed on the machine by default, even if:

  • The project references an older version of the .NET runtime.
  • The latest version of the .NET SDK is a preview release.

You can take advantage of the latest SDK features and enhancements while staying focused on previous versions of the .NET runtime. You can target different versions of the .NET runtime using the same SDK tools.

(Video) ASP.NET vs ASP.NET Core | Difference Between ASP And ASP.NET Core | ASP.NET Tutorial | Simplilearn

In rare cases it may be necessary to use an older version of the SDK. You specify this version in aglobal.json file. The "Use Latest" policy means use onlyglobal.jsonto specify a version of the .NET SDK that is older than the last installed version.

global.jsonit can be placed anywhere in the file hierarchy. The CLI first searches in the project directoryglobal.jsonyou can control which projects of a particularglobal.jsonit is constrained by its place in the file system. The .NET CLI looks for oneglobal.jsonFile by iteratively navigating the path from the current working directory. The firstglobal.jsonThe file found indicates the version used. If this SDK version is installed, this version will be used. If the SDK is specified inglobal.jsonnot found, uses the .NET CLIcorrespondence rulesto select a compatible SDK or fail if none are found.

The following example shows theglobal.jsonSyntax:

{ "SDK": { "Version": "5.0.0" }}

The process for choosing an SDK version is:

  1. Net pointLook out forglobal.jsonFile iteratively, navigating back to the current working directory path.
  2. Net pointuses the SDK specified in the firstglobal.jsonfound.
  3. Net pointUse the latest installed SDK if notglobal.jsonIt's found.

For more information on selecting the SDK version, seecorrespondence rulesjscroll forwardsections of theglobal.json overviewArticle.

Target framework monikers define compile-time APIs

You build your project using the APIs defined in aTarget framework short name(TFM). You specify themtarget framein the project file. Choosetarget frameelement in your project file, as shown in the example below:

<TargetFramework>net5.0</TargetFramework>

You can build your project on several TFMs. Setting up multiple target frameworks is most common for libraries, but can also be done with applications. you indicate atarget frameproperty (plural oftarget frame). Target frames are separated by semicolons, as shown in the following example:

(Video) How to Check .net Version

<TargetFrameworks>net5.0;netcoreapp3.1;net47</TargetFrameworks>

A given SDK supports a fixed set of frameworks, limited to the runtime target framework it ships with. For example, the .NET 5 SDK includes the .NET 5 runtime, which is an implementation ofrot5.0target frame. The .NET 5 SDK supportsnetcoreapp2.0,netcoreapp2.1,netcoreapp3.0, and so on, but notnet6.0(or higher). Install the .NET 6 SDK to compilenet6.0.

.NET-Standard

The .NET standard was a way to target an API surface shared by different .NET implementations. Starting with the release of .NET 5, which is itself an API standard, the .NET standard is of little concern except for one scenario: the .NET standard is useful if you're on .NET and the . NET Framework want to target. .NET 5 implements all versions of the .NET standard.

For more information, see.NET 5 and .NET Standard.

Further development of framework-dependent applications

When you run an app from source withRun dotnet, of aFramework dependent implementationimpostordotnet meuaplicativo.dll, or from oneFramework dependent executableimpostormeuaplicativo.exe, aNet pointexecutable is thehostfor the application

The host selects the latest version of the patch installed on the machine. For example, if you have indicatedrot5.0in your project file and5.0.2the latest .NET Runtime is installed, the5.0.2runtime is used.

if not acceptable5.0.*version is found, a new one5.*version is used. For example, if you have indicatedrot5.0and only5.1.0is installed, the application will run with the5.1.0Runtime This behavior is known as "minor versioning". Lower versions are also not considered. If an acceptable runtime environment is not installed, the application will not run.

Some usage examples demonstrate the behavior when targeting 5.0:

(Video) Stop choosing the “wrong” .NET version

  • ✔️ 5.0 is specified. 5.0.3 is the highest installed patch version. 5.0.3 is used.
  • ❌ 5.0 is specified. There are no 5.0.* versions installed. 3.1.1 is the highest installed runtime. An error message is displayed.
  • ✔️ 5.0 is specified. There are no 5.0.* versions installed. 5.1.0 is the highest installed runtime version. 5.1.0 is used.
  • ❌ 3.0 is specified. There are no 3.x versions installed. 5.0.0 is the highest installed runtime. An error message is displayed.

Updating minor versions has a side effect that may affect end users. Consider the following scenario:

  1. The application states that 5.0 is required.
  2. When run, version 5.0.* will not be installed, but 5.1.0 will. Version 5.1.0 is used.
  3. Later the user installs 5.0.3 and runs the application again, now it uses 5.0.3.

5.0.3 and 5.1.0 may behave differently, particularly in scenarios such as serializing binary data.

Control advanced behavior

The advanced behavior of an application can be configured in four different ways:

  1. Project level configuration, configuration of the<Next>Property:

    <PropertyGroup> <RollForward>LatestMinor</RollForward></PropertyGroup>
  2. Him*.runtimeconfig.jsonoffice hours.

    This file is created when you build your application. If he<Next>property defined in the project is reflected in the*.runtimeconfig.jsonfile like thatscroll forwardVicinity. Users can edit this file to change the behavior of their application.

    { "runtimeOptions": { "tfm": "net5.0", "rollForward": "LatestMinor", "framework": { "name": "Microsoft.NETCore.App", "version": "5.0.0" } }}
  3. HimNet pointof command--roll-forward <valour>Property.

    (Video) [Solved] Dot Net Installation Did Not Succeed | You must first install following version of Dot Net

    When running an application, you can control the advanced behavior from the command line:

    dotnet run --roll-forward LatestMinordotnet myapp.dll --roll-forward LatestMinormyapp.exe --roll-forward LatestMinor
  4. HimDOTNET_ROLL_FORWARDenvironment variable.

priority

The forwarding behavior is defined in the following order when running the application, with higher numbered elements taking precedence over lower numbered elements:

  1. first the*.runtimeconfig.jsonthe configuration file is evaluated.
  2. Then theDOTNET_ROLL_FORWARDThe environment variable is honored and overrides the above check.
  3. Finally any- scroll forwardThe parameter passed to the running application overrides everything else.

Values

Regardless of how you configure the redo settings, use one of the following values ​​to define the behavior:

Valentinadescription
KleinerBy defaultif not specified.
Switch to the lowest major-minor version if the requested minor version is missing. If the requested minor version exists, thelast patchpolicy is used.
ImportantSwitch to the next higher major version available and to the lowest minor version if the requested major version is missing. If the requested major version exists, theKleinerpolicy is used.
last patchProceed with the latest patch version. This value disables minor version expansion.
LastMenorContinue with the highest minor version even if the requested minor version exists.
last importantProceed with the highest major and highest minor version even if the requested major version exists.
deactivateDon't continue, just link to the given version. This policy is not recommended for general use because it disables the ability to roll forward to the latest patches. This value is recommended for testing purposes only.

Standalone deployments include the selected term

You can publish an app likeautonomous distribution. This approach bundles the .NET runtime and libraries with your application. Standalone implementations do not depend on runtime environments. The runtime version is selected at the time of publication, not at runtime.

Himrestore somethingEvent that occurs when version selects the latest patch version from the specified runtime family. For example,publish dotnetselects .NET 5.0.3 if it is the latest patch version in the .NET 5 runtime family. The target framework (including the latest installed security patches) is packaged with the application.

An error occurs when the specified minimum version is not reached for an application.publish dotnetLinks to the latest version of the runtime patch (within a specific major.minor version family).publish dotnetdoes not support the direct semantics ofRun dotnet. For more information on patches and standalone deployments, see the article onRuntime patch selectionwhen implementing .NET applications.

(Video) .NET Framework vs .NET Core vs .NET vs .NET Standard vs C#

Standalone deployments may require a specific patch version. You can override the minimum runtime patch version (for higher or lower versions) in the project file as shown in the following example:

<PropertyGroup> <RuntimeFrameworkVersion>5.0.7</RuntimeFrameworkVersion></PropertyGroup>

HimRuntimeFrameworkVersionThe item overrides the default version policy. For standalone deployments, theRuntimeFrameworkVersionspecifies theexactlyRuntime framework version. For framework-dependent applications, theRuntimeFrameworkVersionspecifies theMinimumrequired version of the runtime framework.

also see

  • Download and install .NET.
  • How to Remove .NET Runtime and SDK.

FAQs

How do I select a .NET version? ›

In order to change default dotnet SDK version, place a global. json file in the current folder or any parent folder with the contents below. You can create the global. json file manually, or use the dotnet cli command dotnet new globaljson .

Which version of .NET should I use? ›

NET Core is best when developing applications on any platform. . NET Core is used for cloud applications or refactoring large enterprise applications into microservices. You should use .

How can I tell what .NET version a website is using? ›

You can find the technology behind this using the built-in tool called “IE Developer Toolbar”. This toolbar, contains a tab called “Network”. In this tab, you can find the necessary details.

How to change .NET version using Command Prompt? ›

Open your project's source folder and, in the address bar, type "cmd" and press Enter. It will open the command prompt with the project path. Execute the following command: dotnet --version .

How do I use a specific version of dotnet? ›

You specify that version in a global. json file. The "use latest" policy means you only use global.
...
The process for selecting an SDK version is:
  1. dotnet searches for a global. ...
  2. dotnet uses the SDK specified in the first global. ...
  3. dotnet uses the latest installed SDK if no global.
Feb 28, 2023

Can I have multiple .NET versions? ›

It is safe to install multiple versions of the . NET Framework on your computer.

Should I use .NET Core 3.1 or .NET 6? ›

NET Core 3.1 has succeeded. For new projects, it's recommended to go with the newest and fastest version, . NET 6, since it is the most flexible and performance-oriented version released so far and will work on every scenario and requirement.

Should I use .NET Standard or .NET 5? ›

NET Standard 2.0 gives you the most reach while supporting . NET 5 ensures that you can leverage the latest platform features for customers that are already on . NET 5. In a couple of years, the choice for reusable libraries will only involve the version number of netX.

Should I target .NET 5 or .NET Standard? ›

We recommend you target . NET Standard 2.0, unless you need to support an earlier version. Most general-purpose libraries should not need APIs outside of .

How to check the version of .NET in Command Prompt? ›

You can also press the Windows key + R shortcut, then enter "cmd" in the Run dialog box. Then, press CTRL + SHIFT + ENTER to open the Command Prompt. Run The Initial Check . Net Version Command: Type in reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s to run the initial check.

What is current .NET version? ›

In November 2021, Microsoft released . NET 6.0, and in November 2022 released . NET 7.0, but only the former is a long-term support (LTS) release. Version. Release date.

What is .NET framework vs .NET Core? ›

. NET Framework includes the developer tools, languages, and libraries needed to develop Windows applications. . NET Core is a complete rewrite intended to make it a more flexible, cross-platform, modular approach to application development.

How do I change .NET Standard to .net 6? ›

NET 6 will put you in a very good position to move to Microservices as the next step.
  1. Step 1 - Understand Your Dependencies. ...
  2. Step 2 - Upgrade the Visual Studio Project (csproj) Format. ...
  3. Step 3 - Multi-target . ...
  4. Step 4 - Fix Code Issues. ...
  5. Step 5 - High-Level Projects. ...
  6. Step 6 - Testing.
Dec 12, 2021

How do I change to .net 6? ›

To upgrade from ASP.NET Core 5.0 to 6.0, see Migrate from ASP.NET Core 5.0 to 6.0.
  1. Prerequisites. Visual Studio. ...
  2. Update .NET SDK version in global.json. ...
  3. Update the target framework. ...
  4. Update package references. ...
  5. Delete bin and obj folders. ...
  6. Minimal hosting model. ...
  7. Update Razor class libraries (RCLs) ...
  8. Blazor.
Jun 3, 2022

How to change the version of .NET core? ›

How to change the . NET Framework Version in Visual Studio
  1. In your Solution Explorer, right-click your project and select Properties.
  2. In Properties, go to the Application option on the side menu.
  3. Locate the Target framework dropdown and select the framework version you need.
Apr 6, 2020

How do I specify .NET SDK version? ›

Checking the version of your . NET Core project
  1. Open your project's source folder and in the address bar, type "cmd" and press Enter. It will open the Command Prompt with the project path.
  2. Execute the following command. dotnet --version. It will display your project's current SDK version, i.e., 2.1. 503 in our case.
Feb 19, 2019

Can .NET 6 run .NET 5 apps? ›

Code built for . NET 5 will run on . NET 6, and you can update it to take advantage of the new release's additional options and APIs.

How do I migrate .NET framework to .NET standard? ›

To do that, complete the following steps:
  1. In Visual Studio, select Analyze and then Portability Analyzer Settings.
  2. In the General Settings window, select . NET Standard 2.0 under Target Platforms, and then choose OK.
  3. Now, open the project file containing the code that needs to target .
Nov 18, 2022

Can .NET 3.5 and 4.8 coexist? ›

Microsoft designed the . NET Framework so that multiple versions of the framework can be installed and used at the same time. This means that there will be no conflict if multiple applications install different versions of the . NET framework on a single computer.

Can .NET 4.6 and 4.7 coexist? ›

Yes, 4.7 overwrites any previously installed 4. x version. Make sure you don't also install 4.6, that will destroy the 4.7 install.

Does installing .NET 4.0 will affect existing .NET applications running on previous versions? ›

No, they can exist alongside eachother. Just like with previous versions. In fact, 4.0 uses completely different directories to store its assemblies in.

Is .NET Core 6 the same as .NET 6? ›

NET 6, though, is ASP.NET Core 6, a major upgrade of Microsoft's open source framework for building modern web applications. ASP.NET Core 6 is built on top of the . NET Core runtime and allows you to build and run applications on Windows, Linux, and macOS. ASP.NET Core 6 combines the features of Web API and MVC.

Is .NET Core 3.1 Obsolete? ›

Net Core Version 3.1 will end on December 13, 2022. QID Detection Logic (Authenticated): This QID looks for the installed versions of . NET Core 3.1 and reports it as End Of Life.

Is .NET 6 still .NET Core? ›

While support for . NET Core 3.1 ends in December 2022, support for . NET 6 will continue until November 2024. Other customers may want to ensure they're upgrading to the latest supported version, so that post-migration they're not already behind a version.

Does .NET 5 replace .NET Standard? ›

NET 5 doesn't replace . NET Standard. New application development can specify the net5. 0 Target Framework Moniker (TFM) for all project types, including class libraries.

Is .NET 5 the same as .NET 5? ›

Also, it is possible to implement Blazor for the creation of client user interfaces with the help of . NET. It is important to note that beginning from version 5, there is no . NET Core anymore, as the .

Is .NET 5 the same as .NET Core? ›

NET Core or . NET Framework. ASP.NET Core 5.0 is based on . NET 5.0 but retains the name "Core" to avoid confusing it with ASP.NET MVC 5.

Does .NET Standard 2.0 work with .NET 6? ›

NET Standard is a set of interfaces that help to guarantee cross-compatibility no matter whether you are running NET Framework or NET 5/6/7. Targeting Netstandard 2.0 or lower means you'll be able to run on NET 5/6/7 or NET Framework 4.

Can I use .NET Standard in .NET Core? ›

Because . NET Core 2.0 implements . NET Standard 2.0, it also has the compatibility mode for referencing . NET Framework libraries.

Is .NET Standard 2.0 compatible with .NET Framework? ›

NET Standard 2.0 specification is now complete. It is supported in . NET Core 2.0, in the . NET Framework 4.6.

What version of .NET Core do I have? ›

NET Core is installed on Windows is: Press Windows + R. Type cmd. On the command prompt, type dotnet --version.

How to check .NET framework version using PowerShell command? ›

PowerShell Method
  1. Download the attached script Get-NetFrameworkVersion.ps1.
  2. Right click the script and select Run With PowerShell.
  3. The last output will be the version of Framework 4 installed:
  4. You are now aware of what version of . NET Framework is running on the Windows computer.
Feb 22, 2023

What is the net command in CMD? ›

Net (command)/User. Net is a Windows command used to view and modify network settings. These activities will show you how to use the net user command. Note: To complete this activity, you must have an administrative user account or know the username and password of an administrator account you can enter when prompted.

Is .NET 4.8 the last? ›

NET Framework 4.8 was the final version of . NET Framework, future work going into the rewritten and cross-platform .

What is the difference between .NET 5 and .NET 6? ›

Platforms

NET 5 and . NET 6 are supported on multiple operating systems, including Windows, Linux, Android, iOS /tvOS, and macOS. The only difference is that . NET 6 is further supported on Windows Arms64 and macOS Apple Silicon while .

How do I upgrade my .NET Core 3.1 to .NET 6? ›

This article describes how to upgrade the solution from . NET Core 3.1 to . NET 6.0 with an example of a web application project.
...
  1. Step 1 - Change the Project Target Framework. ...
  2. Step 2 - Updating Package references. ...
  3. Step 3 - Delete Obj and bin folder. ...
  4. Step 4 - Build the solution.
Jan 10, 2023

Does .NET replace .NET Core? ›

NET Core is the future. With the planned release of a unified platform in 2020, . NET Core will replace .
...
. NET Core vs . NET Framework.
.NET Core.NET Framework
Cross-platform (OS platform): runs on Windows, Linux, and macOSRuns on Windows
4 more rows
Dec 5, 2019

Is .NET and .NET Framework same? ›

.NET and .NET Framework share many of the same components and you can share code across the two. Some key differences include: .NET is cross-platform and runs on Linux, macOS, and Windows. . NET Framework only runs on Windows.

Can I install .NET Framework and .NET Core on the same machine? ›

NET Core installations are completely independent from the version of . NET Framework. In fact, you can actually install multiple version of . NET Core side-by-side on the same machine (unlike .

How do I convert .NET 4.8 to .NET 6? ›

Manual Migration
  1. STEP 1 – Analyze Dependencies. ...
  2. STEP 2 – Prepare for Migration. ...
  3. STEP 3 – Migrate Project File. ...
  4. STEP 4 – Fix Code & Build. ...
  5. STEP 5 – Finally Run & Test your Application on .NET 6.
Feb 8, 2022

How do I migrate from .NET 5 to .NET 6? ›

Migrating from .

NET 5. In Visual Studio, simply right click on your project in Solution Explorer and choose Properties. Under Application > General > Target framework, choose . NET 6.0.

How do I convert .NET Core 3.1 to .NET 5? ›

  1. Prerequisites.
  2. Update .NET Core SDK version in global.json.
  3. Update the target framework.
  4. Delete bin and obj folders.
  5. Changes to Blazor app routing logic in 5.0. 1 and further 5. ...
  6. Update Blazor WebAssembly and Blazor Server projects.
  7. Update Blazor WebAssembly projects.
  8. Update a Blazor Progressive Web Application (PWA)
Jan 4, 2023

Should I use .NET 5 or 6? ›

NET 6.0 has more advantages than working with the . NET 5.0 as . NET 6.0 has more improvement on the performance which also includes some major advantage as it has intelligent code editing and also it is called the fastest full-stack web framework.

Is .NET 6 and .NET Framework different? ›

NET 6 can run on natively Mac and Linux, . NET Framework cannot and you would need a third-party runtime like Mono for that capability. . NET 6 you can compile the framework into your application so the separate framework does not need to be installed to run your app. .

How do I migrate from .NET Framework to .NET 5? ›

Migrating from the . NET Framework to . NET 5.0
  1. Create a New Folder for Your .NET Framework Project.
  2. Create a New File and Add the Code.
  3. Add the .csproj to the Existing Solution.
  4. Configure the Project File to Include Code.
  5. Add NuGet Packages.
Nov 4, 2020

How do I change my target framework to .NET 5? ›

Open the solution with Visual Studio, right-click on the project, click on “Properties”, and on “Target Framework” change from “. NET 3.1” to “. NET 5”: Do the same for the other project's layers, including the unit tests projects.

Can you have multiple versions of .NET Core installed? ›

You may have multiple versions of . NET Core installed on same box and some applications may need some specific version of . NET Core. This is why installers doesn't remove previous versions.

How to check the .NET version in CMD? ›

You can also press the Windows key + R shortcut, then enter "cmd" in the Run dialog box. Then, press CTRL + SHIFT + ENTER to open the Command Prompt. Run The Initial Check . Net Version Command: Type in reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s to run the initial check.

What is the latest version of net? ›

Download .NET
VersionLatest releaseLatest release date
.NET Core 2.12.1.30August 19, 2021
.NET Core 2.02.0.9July 10, 2018
.NET Core 1.11.1.13May 14, 2019
.NET Core 1.01.0.16May 14, 2019
4 more rows

Is .NET 6 the same as .NET Core? ›

NET 6, though, is ASP.NET Core 6, a major upgrade of Microsoft's open source framework for building modern web applications. ASP.NET Core 6 is built on top of the . NET Core runtime and allows you to build and run applications on Windows, Linux, and macOS. ASP.NET Core 6 combines the features of Web API and MVC.

Does .NET 5 replace .NET standard? ›

NET 5 doesn't replace . NET Standard. New application development can specify the net5. 0 Target Framework Moniker (TFM) for all project types, including class libraries.

What is the net command in cmd? ›

Net (command)/User. Net is a Windows command used to view and modify network settings. These activities will show you how to use the net user command. Note: To complete this activity, you must have an administrative user account or know the username and password of an administrator account you can enter when prompted.

What is the difference between .NET 6 and .NET 7? ›

NET 6 is a LTS (Long Term Support) release and will be supported with bug and security fixes for (has to look it up) 3 years. . NET 7 however is a STS (Short Term Support) release and will only be supported for 18 months (6 months beyond the release of . NET 8).

What is the difference between .NET and .NET Framework? ›

Some key differences include: .NET is cross-platform and runs on Linux, macOS, and Windows. . NET Framework only runs on Windows. .NET is open-source and accepts contributions from the community.

Can I still use .NET 5? ›

NET 5.0 is not an LTS release and is therefore supported for 18 months, or 6 months after the next release ships, whichever is longer. . NET 5.0 support will end on May 10, 2022. When . NET 5.0 reaches end of support, applications that use this version will continue to run.

Videos

1. Java vs .Net | Difference between Java and .Net - Which one is Better? | Intellipaat
(Intellipaat)
2. Select List or Dropdown List In ASP.NET Core MVC (.NET 6)
(Sameer Saini)
3. Check .Net Framework Version Installed in Your PC | Windows 10
(MDTechVideos International )
4. C# and .Net in Visual Studio Code ( vscode ) | Set up and Installation Guide | 2022 | IAmUmair
(IAmUmair)
5. How To Get .NET 6 in Visual Studio 2019
(taurius litvinavicius)
6. Upgrading from .NET Framework to .NET 6
(dotnet)
Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated: 04/17/2023

Views: 5887

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.