Skip to content

Instantly share code, notes, and snippets.

@scheffler
Created August 11, 2020 00:11
Show Gist options
  • Save scheffler/78e5bde7314785c695dc83d1bbf5903f to your computer and use it in GitHub Desktop.
Save scheffler/78e5bde7314785c695dc83d1bbf5903f to your computer and use it in GitHub Desktop.
Using System.Windows.Forms in a dotnet core app

With dotnet core 3.x you can have libraries which rely on System.Windows.Forms if you setup you project file properly.

  1. In the Project tag, make sure that you specify WindowsDesktop
  2. Include the UseWindowsForms tag in PropertyGroup
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>core_gdpicture</RootNamespace>
<UseWindowsForms>true</UseWindowsForms>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" />
<PackageReference Include="VSI.GDIPicture.Net" Version="10.0.0.2" />
</ItemGroup>
<ItemGroup>
<None Update="reo_feature_plan.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment