Create a console app named "TrimApp"
Modify .csproj like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<Target Name="ConfigureTrimming"
BeforeTargets="PrepareForILLink">
<ItemGroup>
<ManagedAssemblyToLink Condition="'%(Filename)' == 'TrimApp'">
<IsTrimmable>true</IsTrimmable>
</ManagedAssemblyToLink>
</ItemGroup>
</Target>
</Project>
Publishing this app with:
dotnet publish -r win-x64 /p:PublishTrimmed=true /p:TrimMode=link
Actually fails:
TrimApp -> F:\ILLinker\repro\TrimApp\bin\Debug\net5.0\win-x64\TrimApp.dll
ILLink : error IL1020: No files to link were specified. Use one of '-a|-r|-x' options [F:\ILLinker\repro\TrimApp\TrimApp.csproj]
If I add a project reference to a simple classlib, then linker will actually not fail, but will be given command line where the classlib is treated as the "application assembly" - which leads to deleting the actual app's assembly from the output - producing completely broken app (without failing the build).