If you are using .NET Core 3.0 and above, do the following steps and you are good to go: (I'm going to use .NET Core CLI, but you can use Visual Studio too):
md MyWinFormsApp
optional step
cd MyWinFormsApp
optional step
dotnet new sln -n MyWinFormsApp
optional step, but it's a good idea
dotnet new winforms -n MyWinFormsApp
I'm sorry, this is not optional
dotnet sln add MyWinFormsApp
do this if you did step #3
Okay, you can stop reading my answer and start adding code to the MyWinFormsApp
project. But if you want to work with Form Designer, keep reading.
- Open up
MyWinFormsApp.csproj
file and change <TargetFramework>netcoreapp3.1<TargetFramework>
to <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
(if you are using netcoreapp3.0
don't worry. Change it to <TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
)
- Then add the following
ItemGroup
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
</ItemGroup>
After doing these steps, this is what you should end up with:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
</ItemGroup>
</Project>
- Open up file Program.cs and add the following preprocessor-if
#if NETCOREAPP3_1
Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
Now you can open the MyWinFormsApp
project using Visual Studio 2019 (I think you can use Visual Studio 2017 too, but I'm not sure) and double click on Form1.cs
and you should see this:

Okay, open up Toolbox (Ctrl + W, X) and start adding controls to your application and make it pretty.
You can read more about designer at Windows Forms .NET Core Designer.