This can be discovered by creating a minimal example:
- creating an WPF application and then a new Asp .Net Core Web Api project in the solution.
- If WPF does not reference Asp .Net core, it can be published self-contained without any problems, once it does it will fail to publish.
I tried to add reference for WPF which the only nuget package ‘Swashbuckle.AspNetCore’ in Asp.Net core, and changed the AnyCPU in Configuration to x64 same as Target runtime, but that didn’t prevent the failure.
C# is version 6.0.