I have an SSDT database project which references several other databases.
I am now using the Dac API (DacPackage) with a Microsoft.SqlServer.Dac.DacServices.Deploy() which is picking up the referenced dacpacs correctly because I have set
options.IncludeCompositeObjects = true;
What I would like to do is be able to query the package in memory to get a list of the referenced databases from the dacpac and then verify my runtime configuration is not missing anything.
I cannot find a property or method in DacPackage that allows me to get at this.
Is there a way to do this?
Out of the box, No.
I have raised a connect item against it and hope that it will be in a future version.
I have a github sample on how to do it:
https://github.com/GoEddie/Dacpac-References
Basically you have a .dacpac which is a zip file - inside this you have the model.xml which has a set of CustomData elements, each of these is, amongst other things a reference to another dacpac.
The sample returns these CustomData elements as classes you can query (HeaderParser::GetCustomData) you can also use HeaderParser::DeleteCustomData and HeaderParser::AddCustomData to add one.
If you don't like the sample then you can query and update the xml itself to help with reading the zip file use "System.IO.Packaging.Package" or look in DacHackXml in the sample.