rr-wfm / MSBuild.Sdk.SqlProj

An MSBuild SDK that provides similar functionality to SQL Server Data Tools (.sqlproj) projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consume rules from a Nuget package

ErikEJ opened this issue · comments

@jmezach @jeffrosenberg Do you think this could be possible in any way?

(The NuGet content must be extracted and copied to the SDK NuGet package tools folder before we run dacpactool)

Do they need to be next to the dacpactool or would it be enough to know the path to a rules assembly? Either way I think we can make this work, in a similar way as we reference .dacpac's. It is mostly figuring out the set of NuGet packages that are referenced that contain rules, which could perhaps be marked as such in the .csproj and then either copying the assemblies from there (probably making the assumption that the assembly bears the same name as the package), or passing its path to the tool.

They need to be in the same folder as the dacpactool.

Either way I think we can make this work

That would be amazing!

This also could be useful? https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#generatepathproperty (if the rules package contains the rules dll in the tools folder?)

I guess we can define what we want to those "rules" packages to look like internally, so it shouldn't be an issue to put the rules assembly into the tools folder. We are also defining what "dacpac" packages look like and if I'm not mistaking we also put the .dacpac into the tools folder as well.

Yes, I noticed that the .dacpac files are also in the tools folder, so we could potentially take advantage of the automatic property that points to it these days.

We are using that already for resolving the PackageReference to the actual .dacpac file, see

<PhysicalLocation>$(Pkg%(_ResolvedPackageReference.PackageName))</PhysicalLocation>

Ah! Just proves how bad I am at MsBuild 😄

It is definitely not for the faint of heart ;), although I believe the documentation has improved a bit compared to a couple of years ago when you could barely find any.

I could probably throw something together for this, but I'm fairly pressed for time at the time so I don't really know when I'll get around to it.