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.38k stars 351 forks source link

Include assembly / output path in generated IProjectMetadata if available #2511

Open bjorkstromm opened 4 months ago

bjorkstromm commented 4 months ago

For some Aspire hosting extensions it might be needed to know the output assembly of a referenced project. Before #1726 it was fairly straightforward, but after this change my MSBuild-fu fails me on how to include output assembly.

Example of where output assembly will be needed is e.g. DacFx provisioning support (https://github.com/dotnet/aspire/discussions/1696).

Support for output assembly path could be done in a separate target included by the DacFx Hosting package. But I wonder if it would be feasible to try adding it directly in Aspire.Hosting?

mitchdenny commented 3 months ago

We are currently limited in what we can get from the <ProjectReference /> that we add. If we want to get more we'll need changes to the .NET SDK to allow us to pull more information out.

That said, I'm interested in the DACPAC scenario. I'm wondering whether DacFx could add an "aspire mode" where in addition to to the dacpac, it produces an executable which can be launched by Aspire which then deploys the Dacpac to the SQL instance that we point to to?

bjorkstromm commented 3 months ago

We are currently limited in what we can get from the that we add. If we want to get more we'll need changes to the .NET SDK to allow us to pull more information out.

Before #1726 and the service metadata source gen depended on target FindReferenceAssembliesForReferences it was fairly straightforward to get the path to the ref assembly / dacpac.

One solution is that Aspire DacFX provisioning includes some targets which uses "old" approach with FindReferenceAssembliesForReferences for .sqlproj files. Generated project metadata needs to be partial, but probably not a biggie?

That said, I'm interested in the DACPAC scenario. I'm wondering whether DacFx could add an "aspire mode" where in addition to to the dacpac, it produces an executable which can be launched by Aspire which then deploys the Dacpac to the SQL instance that we point to to?

@dzsquared, what do you think the approach above proposed by @mitchdenny? E.g. that Microsoft.Build.Sql could provide a possibility to generate a .NET executable that could be used to deploy a bundled dacpac.

dzsquared commented 1 month ago

The proposal by @mitchdenny for a .NET command/exe to deploy a dacpac is inline with our current inclination to support dotnet publish with a dacpac. https://github.com/microsoft/DacFx/issues/447

cc @zijchen