I have found the problem. I went through my project and fixed every warning I had. After that everything started working as expected. I cant narrow down exactly what warning caused this issue. I still find it strange though that aspire publish and dotnet publish both did not give me any errors or warnings regarding this issue.