I'm facing the same problem. So far, here's what I found:
Microsoft released a Trim tool that finds unused assemblies and removes them.
With .NET CLI:
dotnet add package Microsoft.Packaging.Tools.Trimming -v 1.1.0-preview1-25818-01
dotnet publish -r win-x64 -c release /p:TrimUnusedDependencies=true
Your application's footprint is now much smaller (normally)
For a better optimization you can use it with ILLinker:
Open nuget.config and add <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
between <packageSource>
Here is an example of what your nuget.config should look like.
Then execute the following commands:
dotnet add package ILLink.Tasks -v 0.1.4-preview-981901
dotnet add package Microsoft.Packaging.Tools.Trimming -v 1.1.0-preview1-25818-01
dotnet publish -r win-x64 -c release /p:TrimUnusedDependencies=true
Using these two tools I managed to divide the size of my application by three.
Source: Reducing the size of self-contained .NET Core applications
I'm still trying to get better optimization. I want to run my ASP.NET Core application (currently 72 MB) in an embedded system with only 10 MB.
If anyone has found a better optimization, I'm a buyer.