sql-server-language-extensions icon indicating copy to clipboard operation
sql-server-language-extensions copied to clipboard

Add Linux support to .NET language extension

Open MarkpageBxl opened this issue 1 year ago • 4 comments

This PR adds Linux support to the .NET language extension, which currently only supports Windows.

This involves the following:

  • Creating scripts for building and shipping the Linux native library. PowerShell was chosen as a scripting language to serve as a potential base for a cross-platform script.
  • The Windows-specific APIs used in the native library have been augmented with Linux library calls, guarded by standard preprocessor defines.
  • Due to differences in the .NET runtime lookup logic in hostfxr between Linux and Windows, using a hardcoded hostfxr library path was a no go for portability (e.g. .NET packages on RHEL and Debian do not install .NET in the same base directories). Instead, we make use of nethost (in the form of the libnethost.a static library provided by the .NET runtime) to first do the hostfxr lookup. This approach has the advantage of honoring DOTNET_ROOT and install_location files if they exist, which hostfxr does not.

Additionally, this bumps references to net6.0 up to net8.0, since the former is EOL.

At this point, this has been tested manually on SQL Server running on Ubuntu 22.04 LTS. A .NET 8.0 assembly was successfully executed.

MarkpageBxl avatar Sep 17 '25 08:09 MarkpageBxl

@microsoft-github-policy-service agree company="Raincode srl"

MarkpageBxl avatar Sep 17 '25 08:09 MarkpageBxl

@MarkpageBxl , have you ever met this error:

Error: Could not find a part of the path '/home/mssql_satellite/externallibrariessandboxprivatepath'

SicongLiu2000 avatar Nov 13 '25 01:11 SicongLiu2000

I have rebased on main, and made an additional fallout fix re the use of the DOTNET_ROOT environment variable in DotnetEnvironment.cpp, as the existing code was Windows only.

MarkpageBxl avatar Mar 27 '26 08:03 MarkpageBxl

I also assume we should probably upgrade to net10.0 at this point, though that could be a separate work item as well.

MarkpageBxl avatar Mar 27 '26 08:03 MarkpageBxl