I am trying to create a .net core 3 class library that references the .net core 3 version of winform (so this assembly can itself be referenced by a .net core 3 WinForm assembly).
A new .net core WinForm project references Microsoft.WindowsDesktop.App.WindowsForms, however I can't find any nuget package with that name.
What do I need to do to reference the .net core 3 winform?
NET Core and language features. Open source improvements to WPF and WinForms for . NET Core.
The answer is no, we cannot use . NET Framework Base Class Library in . NET Core because of compatibility issues. Basically, the libraries which target .
The currently accepted answer appears to be somewhat outdated. The recent syntax requires the target to be specified in the TargetFramework tag, not in the Sdk tag:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
</Project>
More info here
Update: In later versions of VS 2019 (I tried Version 16.8.2) there is a project template for Windows Forms Control Library for .NET Core.
Currently Windows Forms .NET Core is in Preview mode and I don't know any official Nuget package or Project template for Windows Forms Control Library in .NET Core in VS 2019 16.2.2.
But to create a Windows Forms Control Library, you can use the following instructions:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<UseWindowsForms>true</UseWindowsForms>
.Now the project file should be like the following:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
Now you can add Windows forms elements like Form
or UserControl
to this project and build the project without any problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With