While working with .NET Aspire
, I encountered an issue where one of my projects (adg-banner-printer
) wasn’t being included in the aspire publish
process. Here's a breakdown of the troubleshooting steps and the root cause:
-
Internal
Program
Class? I initially suspected the issue might be due to theProgram
class being marked asinternal
. That wasn’t the case. -
Private
Main
Method? Next, I checked whether theMain
method beingprivate
might be the cause. Still no effect. -
Short-lived Console App? I considered whether the fact that the app was short-lived (exits immediately) might cause Aspire to skip it. That wasn’t the reason either.
-
Missing
DockerDefaultTargetOS
? I noticed that the.csproj
file didn’t include aDockerDefaultTargetOS
property, and wondered if that was causing the silent failure. Adding it had no effect. -
Added Another Project (Still Ignored) To rule out project-specific issues, I created another simple console app named
test
. It too was ignored during publish.
By default, .NET Aspire does not include console apps in the publish output. Unless the console app is explicitly referenced in your Aspire AppHost project and configured correctly, it will not be built or containerized — and Aspire provides no warning or error about this.
If you're using console apps in your Aspire solution, make sure they are not console applications. Is this a bug, a feature? No clue.