.NET 8

.NET 8, the latest version of Microsoft's .NET framework, boasts impressive performance, developer productivity, and an array of tools for building cloud-native apps, web, desktop, and mobile applications. The .NET 8 release date is set to coincide with the .NET Conf 2023 event in November.


  1. .NET 8 will be LTS release which means it will be supported for three years.
  2. .NET 8 includes a number of new features and improvements including support for native AOT compilation, server-side rendering for Blazor, and simplified output paths.
  3. .NET 8 is still in Preview, so it is not recommended for use in production applications.
  4. Developers should explore the .NET 8 roadmap and test its new features to get ready for the LTS release in November 2023.

Currently, .NET 8 Preview 3 is available for download and includes a range of improvements, such as changes to build paths, workloads, Microsoft.Extensions, and containers, as well as performance enhancements in JIT, Arm64, and dynamic PGO.

As a long-term support (LTS) release, .NET 8 will be supported for three years. Note that this information relates to a pre-release product that may undergo significant changes before its official release. It's noteworthy that a significant portion of the existing .NET documentation on Microsoft's website has yet to be updated for .NET 8.

What's New in .NET 8

The SDK underwent multiple enhancements and modifications, including breaking changes. In .NET 8, there are several new enhancements and changes that you should be aware of. These include improvements to the dotnet workload clean command, as well as simplified output paths.

In addition, there are updates to the Runtime and Native code generation capabilities, as well as changes to how Containers are handled. Finally, there is a new Environment Variable available for non-root user UID values.

.NET 8 Features

  1. ASP.NET Core 8 Updates in .NET 8:

    ASP.NET Core in .NET 8 Preview 3 boasts several notable enhancements, including:

    1. Native AOT support
    2. Server-side rendering for Blazor
    3. Ability to render Razor components independently of ASP.NET Core
    4. Blazor Sections support
    5. Monitoring of Blazor Server circuit activity
    6. Blazor WebAssembly apps enabled with SIMD by default
    7. Request timeouts
    8. Short circuit routes
  2. Output paths have been simplified:

    .NET 8 Preview 3 has a new feature that simplifies the output path and folder structure for build outputs. Before this update, .NET applications created multiple deep and intricate output paths for various build artifacts. The updated, simplified output path structure aggregates all build outputs into a single location, making it easier for tools to predict.

    To take advantage of the new output path format, you need to set the UseArtifactsOutput property to true in your Directory.Build.props file.

  3. Command to clean up workload packs:

    Workload packs may be left behind after updating .NET SDK or Visual Studio, causing confusion for users. Some users resort to deleting directories manually, which is not recommended. Instead, .NET 8 Preview 3 introduces a new command to clean up leftover workload packs. The command is 'dotnet workload clean'. Use it to safely restore to a known-good state before trying again. The command has two modes of operation, which are discussed next.

    ‘dotnet workload clean’: The 'dotnet workload clean' command performs a garbage collection process for file-based or MSI-based workloads. In this mode, the garbage collection only removes orphaned packs without affecting anything else. Orphaned packs refer to packs from uninstalled versions of the .NET SDK or packs without installation records.

    It only removes orphaned packs from the given SDK version or older. If a newer version of SDK is installed, the command needs to be repeated. If Visual Studio is installed and also manages workloads, 'dotnet workload clean' will display a list of all Visual Studio Workloads installed on the machine. These workloads must be uninstalled via Visual Studio rather than using the .NET SDK CLI. This helps to avoid confusion about why some workloads are not removed after running the 'dotnet workload clean' command.

    ‘dotnet workload clean --all’: Compared to workload clean , workload clean --all is more aggressive as it cleans up every pack on the machine that is not from Visual Studio and is of the current SDK workload installation type. This command also removes all workload installation records for the running .NET SDK feature band and below. However, unlike "workload clean," it does not remove installation records since the manifests are the only way to map a pack to the workload ID, but they may not exist for orphaned packs.

  4. System.Text.Json Serialization:

    System.Text.Json has undergone several improvements, particularly in terms of performance and reliability when used with ASP.NET Core in Native AOT apps. These enhancements include the support for serializing types with required and init properties, which were only previously supported in reflection-based serialization. Additionally, it is now possible to customize the handling of members that are not present in the JSON payload and serialize properties from interface hierarchies. Below is an example of how this works in code.

    IDerived value = new DerivedImplement { Base = 0, Derived =1 };
    JsonSerializer.Serialize(value); // {"Base":0,"Derived":1}
    public interface IBase
        public int Base { get; set; }
    public interface IDerived : IBase
        public int Derived { get; set; }
    public class DerivedImplement : IDerived
        public int Base { get; set; }
        public int Derived { get; set; }

    New naming policies have been added to the JsonNamingPolicy for converting property names to snake_case (with an underscore) and kebab-case (with a hyphen). These policies can be used in a similar manner to the existing JsonNamingPolicy.CamelCase policy. Additionally, the JsonSerializerOptions now has a MakeReadOnly() method that provides explicit control over when a JsonSerializerOptions instance is frozen, which can also be checked using the IsReadOnly property.

What's Next in .NET 8?

If you're interested to expand your knowledge about .NET 8, you may explore the official documentation or resources for .NET 8 Preview 3 for the following:

  1. Methods for working with randomness like GetItems<T>() and Shuffle<T>()
  2. Performance-focused new types
  3. System.Numerics and System.Runtime.Intrinsics namespace improvements
  4. System.ComponentModel.DataAnnotations namespace new Data validation attributes
  5. New extension libraries
  6. Reflection improvements
  7. Native AOT support
  8. These features and improvements offer many exciting possibilities for developers, and exploring them further may help you to take full advantage of .NET 8 Preview 3.

Should I use .NET 7 or 8?

As .NET 8 is still in the Preview version, we will strongly recommend you keep your critical and production applications in previous versions until we have .NET 8 LTS version in hand, likely by November 2023.

But you should definitely explore .NET 8 roadmap and test its new exciting features to get ready yourself.