fays
fays

Reputation: 73

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?

Upvotes: 2

Views: 2358

Answers (2)

John Vottero
John Vottero

Reputation: 925

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");

Upvotes: 1

moljac
moljac

Reputation: 1020

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

Upvotes: 2

Related Questions