Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use .NET Aspire across multiple .NET solutions?

I have three dotnet solutions (and not projects) and each of them is made of a bunch of dotnet projects. I want to encapsulate them in a single Dotnet Aspire solution.

Any idea how to do that?

like image 691
fays Avatar asked Oct 16 '25 20:10

fays


2 Answers

Yes. (Tested)

AppHost is project centric, not solution centric. I integrated project from completely different repo (and thus solution).

Aspire AppHost is ProjectReference based meaning it should work after you add ProjectReferences to Aspire AppHost csproj.

Then you should find generated code for your projects in obj\$(CONFIGURATION)\$(TARGETFRAMEWORK)\Aspire

like image 93
moljac Avatar answered Oct 18 '25 09:10

moljac


I do that by using Aspire's AddExecutable(...) in my AppHost to reference executables built by other solutions.

Here's an example:

var tenantServiceCommand = Path.GetFullPath("../../../tenant/src/TenantService/bin/Debug/net8.0/TenantService.exe");
var tenantServiceWorkingDirectory = Path.GetFullPath("../../../tenant/src/TenantService/bin/Debug/net8.0/");
var tenantService = builder.AddExecutable("tenantService", tenantServiceCommand, tenantServiceWorkingDirectory)
    .WithEndpoint(8020, "https", "tsEndpoint", "ASPNETCORE_HTTPS_PORTS");
like image 38
John Vottero Avatar answered Oct 18 '25 11:10

John Vottero