How do I include contract assemblies in the nupkg

2020-03-26 08:42发布

问题:

I just started using nuget to create some packages for an internal library in our company. This library is comprised of many assemblies, and a lot of them have contract reference assemblies generated from Code Contracts.

I'm using the most straightforward nuget pack approach, which is to pass in the csproj file paths and let it resolve all dependencies between projects. The problem is that it does not include the contract assemblies in the lib folder.

Is there a way to make it also get the contract assemblies and correctly only reference the actual dlls in the projects when the package is installed? I figure this should be automated in some way, since nuget could inspect the project file and know that it generates contract assemblies.

If this required explicit file references it would massively complicate our current process, since I'd have to rearrange files and folders to match the location of the .nuspec files, which I'd love to avoid.

EDIT:

I just found another question which deals with code contracts and nuget packages, but it does not answer my question directly. I figured I'd add the link here though since they deal with almost the same things.