-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support deploying .dacpac from referenced NuGet packages #327
Comments
Looks like Microsoft.Build.Sql uses same structure as the system .dacpacs, so assume it is also using the tools folder https://learn.microsoft.com/en-us/sql/tools/sql-database-projects/concepts/package-references?view=sql-server-ver16&pivots=sq1-visual-studio |
It looks like the Or perhaps we would want to make this more specific for SQL database packages? |
I did some early prototyping for this and already got quite far, see rr-wfm@a98c982. My main problem now is dealing with Central Package Management. When that is enabled the |
So it turns out that different generic constraints do not count towards having different overloads, so with the initially proposed design we would have two methods with the same signature which is not something C# allows. Therefore I've decided to rename the API to It also turns out that the As for the Central Package Management issue I've resolved that for now by adding the @aaronpowell Would love some feedback on this feature :) |
I think it makes most sense to be using a separate method regardless, to clearly indicate the difference in the resolution (via package or via project). For finding the package version when CPM is used, there must be a way to get the version number, as that's needed to be known at build time. Also, if you're using a version range in a |
@aaronpowell There appears to be a |
So it'd potentially add all the transient dependencies down the whole chain of the stack? that's probably not ideal. I don't think it's inherently problematic putting it on the |
I agree, but even if we were to put it on the |
Okay, I did some more experimenting and I think I've figured it out now. See #334 for a first draft of this new feature. I guess I just got hit by dotnet/msbuild#2835 while developing this ;). Still need to write some tests though. |
@ErikEJ @aaronpowell Right, I've added some unit tests to the PR. Adding an integration test is going to be a bit harder, because that would require an actual NuGet package with a What we've done for MSBuild.Sdk.SqlProj is that we basically build a NuGet package as part of the CI pipeline and output it to a pre-defined folder on disk and then add that folder as a NuGet package source and install the package from there. That does add quite a bit of complexity to the pipeline however. Not sure if that's a route we'd want to take here? |
@jmezach I can publish Chinook as a NuGet package, if that would help? |
@jmezach Created a package using our latest template - interesting dependency tree? Maybe we should improve this in the SDK or the template? |
That sounds like a bug in MSBuild.Sdk.SqlProj that we should probably fix. |
Related to an existing integration?
Yes
Existing integration
SqlDatabaseProjects
Overview
A feature I would like to add to the existing SqlDatabaseProjects integration is the ability to publish a .dacpac from a NuGet package referenced by the AppHost project. At our company we already have an existing ecosystem of NuGet packages that contain a
.dacpac
and this is in fact one of the supported scenarios in MSBuild.Sdk.SqlProj. All these packages have essentially the same semantics, in the sense that the package contains atools
folder in which we can then find a.dacpac
file that has the same name as the NuGet Package ID (ie. if the package is calledMyDatabasePackage.nupkg
there would be atools\MyDatabasePackage.dacpac
within that package). I'm not sure if Microsoft.Build.Sql has the same semantics though. That being said, we could probably support custom paths fairly easily by providing an overload that would allow one to specify the path within the package.Usage example
I was thinking of something along the following lines:
In case someone would want to customize the path to the
.dacpac
within the package we could provide an overload like so:Breaking change?
No
Alternatives
We already support deploying a
.dacpac
directly from an arbitrary path using something like:Although this works just fine, it will be hard for developers to figure out the right path to the
.dacpac
from a referenced NuGet package. These usually reside in the NuGet package cache, but will change every time the package reference is updated, make this code brittle.Additional context
The proposed solution is akin to the existing solution for referenced projects, but this mechanism doesn't currently exist for referenced packages within Aspire afaik. I haven't looked in detail yet at how Aspire currently does this for projects, but maybe something similar could be created for referenced packages as well. Perhaps this could be achieved by adding some MSBuild logic to CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects for the time being, which would generate a class similar to
Projects
that exposesIPackageMetadata
? I would love some input from the Aspire folks on this./cc @ErikEJ
Help us help you
Yes, I'd like to be assigned to work on this item
The text was updated successfully, but these errors were encountered: