Download the SDK using Download .NET 8.0 (Linux, macOS, and Windows) (microsoft.com) and install it.
To enable projects to target the .NET 8 preview framework, the preview option in Visual Studio needs to be enabled, otherwise the option to target .NET 8 will not be available as shown below when setting up a new project (or trying to upgrade an existing one).
To allow .NET 8 Preview to be used as a target framework for projects, the preview option needs to be enabled in Visual Studio.
Open Visual Studio and select "Continue without code"