dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.35k stars 344 forks source link

Consume Aspire.ServiceDefaults from services using non-web sdk, e.g. Microsoft.NET.Sdk.Worker #4045

Open rmja opened 1 month ago

rmja commented 1 month ago

I am currently in the process of introducing aspire in a larger project. There are several worker services that uses the Microsoft.NET.Sdk.Worker sdk and are hosted in Docker containers using the mcr.microsoft.com/dotnet/runtime:8.0-alpine image. It seems that when such a worker service takes a dependency on the *.Aspire.ServiceDefaults project then that image is not enough anymore as the *.Aspire.ServiceDefaults project has a reference to OpenTelemetry.Instrumentation.AspNetCore which in turn has a framework reference to Microsoft.AspNetCore.App.

What is best path here? Should I simply ignore this and use mcr.microsoft.com/dotnet/aspnet:8.0-alpine as the docker base image for all (also non-web) services, or is it a bug that that the *.Aspire.ServiceDefaults project requires the web sdk? Another option would of cause be to split *.Aspire.ServiceDefaults into two projects, a web and non-web.

rmja commented 1 month ago

Could someone add a comment on whether the ServiceDefaults project and hence all projects depending on it is expected to require the full aspnet runtime, or whether this is a bug?