How to Add Target OS in Visual Studio?

Viewed 30

I want to add linux as one of the target OS, how can I do that?

enter image description here

1 Answers

Target OS sets TargetFramework property of the .csproj. There are no target frameworks specific for linux cause it seems there are no system specific API implemented/exposed by .NET at the moment, so None (net6.0 for TargetFramework property) is an option to go. From .NET 5+ OS-specific TFMs part of the docs:

The net5.0 and net6.0 TFMs include technologies that work across different platforms. Specifying an OS-specific TFM makes APIs that are specific to an operating system available to your app, for example, Windows Forms or iOS bindings. OS-specific TFMs also inherit every API available to their base TFM, for example, the net5.0 TFM.

.NET 5 introduced the net5.0-windows OS-specific TFM, which includes Windows-specific bindings for WinForms, WPF, and UWP APIs. .NET 6 introduces further OS-specific TFMs.

What you can specify is Runtime Identifier (RID):

RID values are used to identify target platforms where the application runs. They're used by .NET packages to represent platform-specific assets in NuGet packages. The following values are examples of RIDs: linux-x64, ubuntu.14.04-x64, win7-x64, or osx.10.12-x64.
For the packages with native dependencies, the RID designates on which platforms the package can be restored.

Currently available Linux RIDs are described here and full list is here.

Related