I found an answer on CodeProject which worked for me.
Open your project file, the *.csproj
file so you can edit it as a text file. If like me you were targeting net6.0
you'll see something like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>WinExe</OutputType>
</PropertyGroup>
</Project>
Now, instead of net6.0
you need to target net6.0-windows
and you also have to set the UseWpf
-flag. Then your *.csproj
file should like something like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWpf>true</UseWpf>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>WinExe</OutputType>
</PropertyGroup>
</Project>