# Stripping extra dependencies in .NET NativeAOT apps using linker substitutions

DevFeed: [Stripping extra dependencies in .NET NativeAOT apps using linker substitutions](<https://devfeed.tech/articles/stripping-extra-dependencies-in-net-nativeaot-apps-using-linker-substitutions-65543.md>)

Original publisher: [Read original article](<https://andrewlock.net/stripping-extra-dependencies-in-.net-nativeaot-apps-using-linker-substitutions/>)

Author: Andrew Lock

Published: 2026-10-06T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [native aot](<https://devfeed.tech/topics/native-aot.md>), [trimming](<https://devfeed.tech/topics/trimming.md>), [toolchain](<https://devfeed.tech/topics/toolchain.md>), [.NET](<https://devfeed.tech/topics/net.md>), [linker](<https://devfeed.tech/topics/linker.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [azure](<https://devfeed.tech/tags/azure.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [core](<https://devfeed.tech/tags/core.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [dotnet](<https://devfeed.tech/tags/dotnet.md>), [guide](<https://devfeed.tech/tags/guide.md>), [linker](<https://devfeed.tech/tags/linker.md>), [nativeaot](<https://devfeed.tech/tags/nativeaot.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-core-observability](<https://devfeed.tech/tags/net-core-observability.md>), [net-sdk](<https://devfeed.tech/tags/net-sdk.md>), [observability](<https://devfeed.tech/tags/observability.md>)

## AI overview

The article explains how linker substitutions in a .NET NativeAOT application can replace a runtime property check with a compile-time constant, allowing additional dead-code elimination and removal of unused dependencies. In the described case, the change reduced the binary size by 22-25%.

## Source excerpt

In this post I describe how to perform method-substitutions with the NativeAOT linker to remove additional dependencies that the linker couldn't see were unused