Summary
PgProj's ReferenceResolver only resolves local ArtifactReferences today; NuGet restore of .pgpkg packages is explicitly flagged as a "planned follow-up". This blocks the recommended SSDT composition model where a large database is split into reusable, versioned schema packages consumed by id+version. Adding NuGet PackageReference support (consume) and dotnet pack of a project into a .nupkg (publish) closes this parity gap.
SSDT / SqlPackage reference
In SSDT, a database project can declare a PackageReference to a .dacpac distributed as a NuGet package, restore it via dotnet add package / dotnet restore, and itself be produced as a consumable package via dotnet pack. This lets teams factor a monolithic schema into a shared "common" project plus dependent projects that reference it by package id and version, with build-time resolution feeding the deploy/compare model. Cross-project references contribute objects to the composite model used at build and publish time.
Proposed PgProj approach
Extend the existing artifact pipeline rather than inventing a new format:
- Pack: reuse the SDK packaging path that already packs the CLI as a tool to also pack the project's built
.pgpkg into a .nupkg (a dotnet pack target emitting the .pgpkg as TfmSpecificPackageFile content under a known folder, with id/version metadata).
- Restore + resolve: teach
ReferenceResolver to accept PackageReference entries, run NuGet restore, locate the restored .pgpkg in the global packages folder, and feed its objects into the same composite model that ArtifactReference already populates — so SchemaCompare, IdentityDiffEngine, DeployScriptGenerator, RiskAnalyzer, and PhasedDeployer consume referenced objects transparently.
- Scope to same-database composition: because PG has no three-part names (cross-DB is FDW/dblink only), the deliverable is build-time composite models and reference resolution for a shared "common schema" project, not runtime cross-DB calls. Referenced objects are visible to the build/compare model but the resolver must not emit deploy DDL for objects owned by a referenced package (reference-only, mirroring SSDT "same database" reference semantics).
- Validate via the shadow-DB harness: a consumer project that references a packed common-schema package must build, compare, and deploy identically to the inlined-objects baseline, and
profiles must round-trip unchanged.
Acceptance criteria
References
- MicrosoftDocs/sql-docs:
docs/tools/sql-database-projects/concepts/package-references.md
- Priority: medium
Summary
PgProj's
ReferenceResolveronly resolves localArtifactReferences today; NuGet restore of.pgpkgpackages is explicitly flagged as a "planned follow-up". This blocks the recommended SSDT composition model where a large database is split into reusable, versioned schema packages consumed by id+version. Adding NuGetPackageReferencesupport (consume) anddotnet packof a project into a.nupkg(publish) closes this parity gap.SSDT / SqlPackage reference
In SSDT, a database project can declare a
PackageReferenceto a.dacpacdistributed as a NuGet package, restore it viadotnet add package/dotnet restore, and itself be produced as a consumable package viadotnet pack. This lets teams factor a monolithic schema into a shared "common" project plus dependent projects that reference it by package id and version, with build-time resolution feeding the deploy/compare model. Cross-project references contribute objects to the composite model used at build and publish time.Proposed PgProj approach
Extend the existing artifact pipeline rather than inventing a new format:
.pgpkginto a.nupkg(adotnet packtarget emitting the.pgpkgasTfmSpecificPackageFilecontent under a known folder, with id/version metadata).ReferenceResolverto acceptPackageReferenceentries, run NuGet restore, locate the restored.pgpkgin the global packages folder, and feed its objects into the same composite model thatArtifactReferencealready populates — soSchemaCompare,IdentityDiffEngine,DeployScriptGenerator,RiskAnalyzer, andPhasedDeployerconsume referenced objects transparently.profilesmust round-trip unchanged.Acceptance criteria
dotnet packon a PgProj project produces a.nupkgcontaining the project's.pgpkgwith correct id/version metadata.PackageReferencein a.pgprojis restored via NuGet and its.pgpkgis located and loaded byReferenceResolver.SchemaCompare/IdentityDiffEnginebut are treated as reference-only (no deploy DDL is generated for them).DeployScriptGenerator/PhasedDeployerwith output equivalent to the inlined-objects baseline (verified on the shadow-DB harness).References
docs/tools/sql-database-projects/concepts/package-references.md