Skip to content


Fix UseManagedNtlm linker substitutions (#90957)
Browse files Browse the repository at this point in the history
* Fix UseManagedNtlm linker Substitutions

- Specify the default value (false) for the feature on Linux so the linker runs the substitution when no value was specified by the user.
- Make the `UseManagedNtlm` property public because the linker and IL compiler doesn't support substitution of private properties.
- Add `--ignore-substitutions` switch to ILLink during library build to prevent the substitution with default value taking place.

* Revert unnecessary changes, document _UseManagedNtlm switch

* Set _UseManagedNtlm in NativeAOT integration

* Revert unnecessary change, move default values for trimming properties from NativeAOT targets to ILLink ones

* Fix build
  • Loading branch information
filipnavara committed Aug 29, 2023
1 parent 33a4319 commit cf3328c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/workflow/trimming/
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ configurations but their defaults might vary as any SDK can set the defaults dif
| _AggressiveAttributeTrimming | System.AggressiveAttributeTrimming | When set to true, aggressively trims attributes to allow for the most size savings possible, even if it could result in runtime behavior changes |
| JsonSerializerIsReflectionEnabledByDefault | System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault | When set to false, disables using reflection as the default contract resolver in System.Text.Json |
| EnableGeneratedComInterfaceComImportInterop | System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop | When set to true, enables casting source-generated COM object wrappers to built-in COM-based COM interfaces. |
| _UseManagedNtlm | System.Net.Security.UseManagedNtlm | When set to true, uses built-in managed implementation of NTLM and SPNEGO algorithm for HTTP, SMTP authentication, and NegotiateAuthentication API instead of system provided GSSAPI implementation. |

Any feature-switch which defines property can be set in csproj file or
on the command line as any other MSBuild property. Those without predefined property name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ The .NET Foundation licenses this file to you under the MIT license.

<IlcArg Condition="$(IlcDisableReflection) == 'true'" Include="--feature:System.Reflection.IsReflectionExecutionAvailable=false" />

<!-- Linux Bionic doesn't ship GSSAPI, so enable managed implementation -->
<IlcArg Condition="'$(_linuxLibcFlavor)' == 'bionic'" Include="--feature:System.Net.Security.UseManagedNtlm=true" />

<!-- The managed debugging support in libraries is unused - trim it -->
<IlcArg Condition="'$(IlcKeepManagedDebuggerSupport)' != 'true'" Include="--feature:System.Diagnostics.Debugger.IsSupported=false" />
<IlcArg Condition="'$(UseWindowsThreadPool)' != '' and '$(_targetOS)' == 'win'" Include="--feature:System.Threading.ThreadPool.UseWindowsThreadPool=$(UseWindowsThreadPool)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Copyright (c) .NET Foundation. All rights reserved.
<_EnableConsumingManagedCodeFromNativeHosting Condition="'$(_EnableConsumingManagedCodeFromNativeHosting)' == ''">false</_EnableConsumingManagedCodeFromNativeHosting>
<VerifyDependencyInjectionOpenGenericServiceTrimmability Condition="'$(VerifyDependencyInjectionOpenGenericServiceTrimmability)' == ''">true</VerifyDependencyInjectionOpenGenericServiceTrimmability>
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(JsonSerializerIsReflectionEnabledByDefault)' == ''">false</JsonSerializerIsReflectionEnabledByDefault>
<!-- Linux Bionic doesn't ship GSSAPI, so enable managed implementation -->
<_UseManagedNtlm Condition="'$(_UseManagedNtlm)' == '' and $(RuntimeIdentifier.StartsWith('linux-bionic'))">true</_UseManagedNtlm>
<!-- Trim managed NTLM on Linux when it's not explicitly requested -->
<_UseManagedNtlm Condition="'$(_UseManagedNtlm)' == '' and $(RuntimeIdentifier.StartsWith('linux'))">false</_UseManagedNtlm>

Expand Down

0 comments on commit cf3328c

Please sign in to comment.