How to target .NET 6.0 with Visual Studio 2019?

john zyd 421 Reputation points
2021-11-09T09:12:02.417+00:00

Hello:
I know .NET 6.0 is released, but I don’t know how to create a WinForm App targeting .NET 6.0 with Visual Studio 2019 (Version 16.11.5) on Windows 10 (Version 21H1)
I can download the following packages:
.NET 6.0 SDK (v6.0.100) - Windows x64 Installer!
.NET 6.0 Desktop Runtime (v6.0.0) - Windows x64 Installer!
But when I create a WinForm App project, there is no place to target .NET 6.0.
Please give detailed instructions.
I know I can use Visual Studio 2022 can target .NET 6.0, but currently we can’t use Visual Studio 2022 yet, have to wait at least one year.
Thanks,

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,008 questions
0 comments No comments
{count} votes

Accepted answer
  1. Karen Payne MVP 35,436 Reputation points
    2021-11-09T09:44:58.98+00:00

    First off, for proof the following works, the following Visual Studio Solution was created in VS2019, runs fine. As a side note I have samples for DateOnly and TimeOnly struct and a few other goodies.

    Under Options, Environment, Preview Features set Use previews of the .NET SDK to true, restart Visual Studio.

    Restart, in a Visual Studio solution create a new Windows Form app.

    To validate double click the project file in Solution Explorer and you should see

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net6.0-windows</TargetFramework>
        <Nullable>enable</Nullable>
        <UseWindowsForms>true</UseWindowsForms>
      </PropertyGroup>
    
    </Project>
    

    Or create via PowerShell at the root folder of a Visual Studio solution

    dotnet new winforms --name WinApp1 --output WinApp1
    
    dotnet sln add .\WinApp1\WinApp1.csproj
    
    6 people found this answer helpful.

9 additional answers

Sort by: Most helpful
  1. Karen Payne MVP 35,436 Reputation points
    2022-10-14T21:58:21.863+00:00

    To those still trying, best to bite the bullet and move to VS2022 for .NET Core 6 or stay with VS2019 and .NET Core 5. VS2022 has a better user experience overall. And note that .NET Core 6 has a three year lifespan even if it's LTS.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.