MSBuild.Sdk.SqlProj icon indicating copy to clipboard operation
MSBuild.Sdk.SqlProj copied to clipboard

Transitive references treated as though it's part of the top level project

Open wilstoff opened this issue 2 years ago • 2 comments

While I may have caused this in https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/pull/329, i'm not really seeing it currently.

The behavior is as such:

Project A depends on nothing has User MyUser in its schema Project B depends on A as a DatabaseLiteralValue Project C depends on B as linked server passing both DatabaseSqlCmdVariable and ServerSqlCmdVariable Project C also has a User MyUser in its schema

When i build a project like this i get errors saying

The Model already has an element that has the same name MyUser

I believe this is because when building C, project A is passed into the DacpacTool.dll as a reference with no parameters

-r "ProjectA;dbl=|dbv=|srv=;"

Which then i believe the build tool treats it as a reference meant to be apart of this project instead a separate server dependency. I think there needs to be a way to treat multi layer dependencies different than just walking the tree of dependencies and removing dbl/dbv/srv. I understand the reason to remove dbl, because Project A is most likely no longer a literal local db server reference anymore (relative to C), but Project A in this case is definitely not a complete subset of C, even though it may have similar users and share some tables.

wilstoff avatar Nov 14 '22 14:11 wilstoff

Did you ever find a way to work around this? I am having the same issue.

nholland20 avatar Aug 23 '23 22:08 nholland20

We did find a work around, I'd have to go look again, but i believe just adding your full dependency chain to the list of projects seems to be where we ended up. So if C depends on B depends on A, then the workaround is to have C depend on B and A directly. That is at least what i recall. Can confirm more tomorrow..

Yea confirmed it was hacked by directly referencing implied dependencies in the top level instead of relying on dependency of dependency. It then understood the duplication. We also have some SuppressMissingDependenciesErrors="True" for a few of these.

wilstoff avatar Aug 23 '23 23:08 wilstoff