How to exclude a .NET 5.0 project from build depending on the OS

187 Views Asked by At

We have a Visual Studio solution with several .NET 5.0 projects, one of which is a Windows Application (TargetFramework is net5.0-windows). It obviously fails to build on Linux and Mac. How can we make it so that it would build or not build, depending on the OS? The scenarios we need to support are:

  1. Building from Visual Studio on Windows.
  2. Building from JetBrains Rider on Windows and Mac.
  3. Building from command line on Windows, Mac and Linux. For command line we currently use dotnet build, as well as dotnet test and dotnet pack which build the solution first.
0

There are 0 best solutions below