'Error when building .NET 5 Class library - NETSDK1136

I am getting following error, when building my .NET 5 application , which was working fine before

The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF

I am aware this can be fixed by adding -windows

<TargetFramework>net5.0-windows</TargetFramework>

but I don't want to take that route, it works fine without this for other developer's in my team

is there anyway i can fix this issue without modifying project file



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source