The .NET IL linker is built upon the mono linker which has been around since 2006. Its purpose is to strip away all unnecessary code in your app that is not reached by any code path. In short, it reduces the size of your application, which is always a good thing. Xamarin has been using the mono linker to decrease the app size for iOS & Android apps for quiet some time. And now .NET wants in on the action.

How does the linker know what to remove?

Simply put the linker uses a mark-and-sweep algorithm to determine unused code libraries. In the marking phase, the linker runs through the IL and marks code utilized in classes, methods, properties. When the marking phase is done the sweep phase begins removing code that wasn't marked during the initial phase.

Sample project

Using the sample project provided by Microsoft you can publish the app with the following command: dotnet publish -c release -r win-x64 /p:ShowLinkerSizeComparison=true
Doing this will output a neat table, showing what assemblies was partly or completely removed from the application. Here's a screenshot of the output from the sample app:

Linker output from the sample app.

Reading through the instructions in the GitHub repository, they boast an app size reduction of 50% in trivial cases and an even more favorable decrease for larger applications.

Early days

This is still an experimental feature, but the team intends to release it in a subsequent .NET Core release. One of the drawbacks of being an early adopter is that your app needs to be self-contained in order for the linker to work. This means you have to ship your target runtime along with your app, which has its own sets of drawbacks. Furthermore linking only happens during publishing, so now you need to test the app more diligently after publishing.

All things taken into account, I think this is an awesome feature coming to the .NET Core platform (hopefully soon) and one I'll most definitely play around with. You can already install a preview nuget and try it out yourself! Maybe you've already tried it, and if you have, what kind of reduction did you get? I'd love to see your results in the comments.