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.
10,908 questions
0 comments No comments
{count} votes

Accepted answer
  1. Karen Payne MVP 35,421 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. Jeroen van Langen 1 Reputation point
    2022-08-04T06:36:20.757+00:00

    If it should be possible, I must have it running. I'll try it again. Thanks.

    0 comments No comments

  2. Robin Erlacher 1 Reputation point
    2022-09-13T11:55:51.573+00:00

    i installed the .net 6 sdk and that's it.
    i just can't select .net 6 from the visual studio create solution wizard, but when i select .net 5 and then switch it to .net 6 within the csproj file, i can compile and other .net 6 projects run aswell.

    i'm using visual studio 2019 community and haven't installed vs2022 on my private machines.


  3. Maksym Zaiarniuk 1 Reputation point
    2022-09-13T13:19:45.79+00:00

    SAME 16.5.4 com and 16.6.0 ent;
    will try update to latest vs 19

    0 comments No comments

  4. charlievog 1 Reputation point
    2022-09-13T20:51:14.033+00:00

    Was able to make the sample WinApp1 that runs with vs 2019 after commenting out the line: ApplicationConfiguration.Initialize();. I haven't been able to make it work for an MVC web app, however.

    0 comments No comments

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.