Visual Studio SSDT Database Project - add database reference without inheriting sqlcmd variables

35 Views Asked by At

I have several related SSDT SQL Database (.sqlproj) projects in a Visual Studio Solution. Each project has a set of SQLCMD variables and we use the Database Reference feature to enable cross-project/cross-DB references with build time integrity checks.

The problem: when creating a database reference, the SQLCMD variables from the referenced project are inherited by the referencing project, even though they are irrelevant to the referencing project.

At publish time, this results in the *.publishprofile.xml file also inheriting the SQLCMD variables.

So if I have two projects:

  • Project One with Variables: A, B
  • Project Two with Variables: C, D
  • a Database Reference from Project Two to Project One

Then at publish time, Project Two requests inputs to parameters A, B, C and D. Parameters A and B are completely irrelevant to publishing Project Two. I can set the values of A and B to any value at all and it will result in the exact same deployed artifact.

What's the rationale for inheriting these variables and is there any way I can exclude them from the publish profile and at Publish time?

Sidenote: The reality is we have 5-10 parameters per project and sometimes chained references across 3-4 projects. This is really confusing our developers as they are not sure which variables are relevant to the project being published and which are inherited. We can solve this with better developer documentation, etc., but it seems optimal to just exclude the inherited variables if possible.

0

There are 0 best solutions below