Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Idea] .NET Aspire Integration #584

Closed
jmezach opened this issue Jul 17, 2024 · 13 comments
Closed

[Idea] .NET Aspire Integration #584

jmezach opened this issue Jul 17, 2024 · 13 comments
Labels
enhancement New feature or request

Comments

@jmezach
Copy link
Member

jmezach commented Jul 17, 2024

I just had a completely random thought that perhaps could be interesting. Would it be useful to have some kind of integration with .NET Aspire where one could spin up a SQL Server container and deploy a MSBuild.Sdk.SqlProj project to it.

Definitely interested in what @jeffrosenberg and @ErikEJ think, but if you're a user of this project please let us know if this would be interesting 🤔

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 17, 2024

Yeah, I have been thinking the same, some kind if synergy here seems useful.

@jmezach
Copy link
Member Author

jmezach commented Jul 17, 2024

Perhaps something like:

var databaseProject = builder.AddProject<Projects.MyDatabaseProject>();
var db = builder.AddSqlServer("sql")
    .AddDatabase("db")
    .WithDatabaseProject(databaseProject)

Which would then result in a running SQL Server container named sql with a database named db and the referenced database project deployed to it.

@jmezach jmezach pinned this issue Jul 17, 2024
@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 17, 2024

Do you mean WithDatabaseProject(databaseproject) ?

@jmezach
Copy link
Member Author

jmezach commented Jul 17, 2024

That would be the main API yes. Of course the hard part is figuring out what that is going to do. It would probably involve running sqlpackage somehow. Not sure if that is included in the SQL containers though

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 17, 2024

Sqlpackage is easy to install:

dotnet tool install Microsoft.SqlPackage

With a connection string, would it be needed inside the container? (It only runs on certain Linux distributions)

@jmezach
Copy link
Member Author

jmezach commented Jul 17, 2024

I guess we could use a locally installed sqlpackage. We can get the connection string from the SQL resource and I'm guessing we can get the path to the dacpac from the project resource. If we can put those together we can make it work.

Might be able to throw some early prototype together on Friday.

@ErikEJ ErikEJ added the enhancement New feature or request label Jul 18, 2024
@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 21, 2024

I have been thinking about ASPIRE0004 and reading about resource references in the apphost.

Maybe what we really want to do is some thing like this?

var builder = DistributedApplication.CreateBuilder(args);

builder.AddSqlServer("sql")
       .AddDatabase("test")
       .WithDaccpac("MyDacpac");

builder.Build().Run();

The WithDacpac extension method then has some clever ways of finding the location of the specified dacpac and publishing it.

Could be a .dacpac included as content, even pointing to another folder in the solution?

Could be a MsBuild.Sdk.Sqlproj project in the solution?

Or a .nupkg with a .dacpac created by MsBuild.SDK .SqlProj

@jmezach
Copy link
Member Author

jmezach commented Jul 21, 2024

I can see the use case of having an arbitrary .dacpac file somewhere on disk and being able to publish that. I think we could add another extension method that would allow you to just specify the path to the .dacpac directly.

Being able to reference a NuGet package build by MSBuild.Sdk.SqlProj in your AppHost project and deploying that is also interesting and something we could probably easily support.

Not so sure if it makes much sense though when your MSBuild.Sdk.SqlProj is in the same solution as your AppHost project. It feels to me like overkill to have to first package up your project into a NuGet package and then reference that. Will also slow down the inner loop imho. Just being able to reference the project from the AppHost and deploying that is a smoother experience I think, except for the warning we're getting.

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 21, 2024

Agree the nuget option seems cumbersome and anti "inner loop"

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 23, 2024

Stumbled upon this: dotnet/aspire#1696 - I think we are not blocked in the same manner.

@ErikEJ
Copy link
Collaborator

ErikEJ commented Jul 23, 2024

And this from one of the Aspire architects: dotnet/aspire#2511 (comment)

@ErikEJ
Copy link
Collaborator

ErikEJ commented Nov 13, 2024

@jmezach Time to close this 🥳 ??

@jmezach
Copy link
Member Author

jmezach commented Nov 13, 2024

@ErikEJ Yes!

We have decided to add this integration to the CommunityToolkit for Aspire. Thanks to everyone who has helped us shape this feature. We highly recommend migrating to the CommunityToolkit version of this integration.

@jmezach jmezach closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants