3

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.

Community
  • 1
  • 1
julealgon
  • 7,072
  • 3
  • 32
  • 77
  • Why didn't the answers in the other question (by Cory Nelson) answer your question? Also, there's no need to rearrange files and folders as Nuspec file's source may be a full path to the file, rather than relative. – Peas Feb 01 '15 at 22:17
  • His answer is only useful to those including the files explicitly, which I'd obviously like to avoid. I'm calling `nuget pack` directly against a csproj file, not against a nuspec one. Also, absolute paths are worthless in my scenario, since this needs to run in the build server. I need to either generate it automatically (which is ideal) or at least be able to use relative paths and make it work with multiple projects and dependencies between them. I tried this second approach, but the BasePath argument doesn't seem to carry on to dependent projects and I get a bunch of file not found errors. – julealgon Feb 03 '15 at 12:40
  • @Peas This question is specific to generating it automatically though. If that was possible somehow I'd use that. The pack command already get's the xml documentation file, and I wonder if there is a way to make it also fetch the contract assemblies. – julealgon Feb 03 '15 at 12:41
  • @julealgon Did you ever find a solution to your problem? – Mikkel R. Lund Apr 16 '16 at 10:19
  • 1
    @Mikkel Not yet. I've since moved to another company and we are currently not using code contracts. It's very possible I'll be having this issue again in the future though, since its such a common scenario. – julealgon Apr 17 '16 at 10:42

0 Answers0