Open t-mxcom opened 4 years ago
You could use the code here to delete and add the master reference in the .dacpac before publishing: https://github.com/GoEddie/Dacpac-References/blob/master/src/DacpacHeaderParser.Tests/WriteHeaderTests.cs
Thanks for the link!
Of course, modifying the DACPAC file before the deployment is a way of solving the problem - but I'd rather call it a "workaround" than a "solution". Especially as it works with sqlpackage.exe
without prior modification.
Do you know, where I can file this issue so it will receive attention from the DacFx developers?
I am facing the same issue too. I have some views who are referring to the master database information schema views. Please let me know if any solution is identified to fix this one.
Introduction
My solution makes use of the Microsoft.SqlServer.DacFx.x64 (v150.4826.1) NuGet-package to programmatically publish a DACPAC, built using Visual Studio 2019 (Version 16.6.2) and SQL Server Data Tools (16.0.62006.03190), to an existing database.
The DACPAC references types contained in the
master.dacpac
file which is referenced in themodel.xml
file as follows:Before starting the publish operation, both DACPACs are copied to the same directory:
Issue
When publishing the DACPAC using
C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe
, themaster.dacpac
of the same directory (MyDirectory
) is used and the operation works.But when publishing the same file using the DacFx assemblies, they try to load
master.dacpac
from exactly the same directory as specified in the reference definition in the metadata (C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\SQLDB\EXTENSIONS\SQLSERVER\100\SQLSCHEMAS\MASTER.DACPAC
) which of course doesn't exist on a production machine. Thus the operation failes.(Timestamps were added by my application)
How to solve this?
Is there a way to specify additional directories, where the DacFx assemblies look for referenced DACPACs? Is there something like a "reference resolving event" that can be handled by my application returning the path or a stream to the referenced DACPAC? Are there any other options, that make the DacFx assemblies incorporate the source DACPAC's directory when searching for referenced DACPACs?
Is there anything else that
SqlPackage.exe
does additionally which makes the reference discovery work and which I could also add to my application?Thank you for your help!