Nuget Pack Runner, .csproj, and project references


We have a .csproj that is being built into a nuget package by TC7.0 via the .csproj file. This project includes some referenced assemblies, that are marked as copy local. However when I look in the package artifact that is built, the assemblies are not there, the package contains only the .dll for the library itself.

After some googling I found this answer from Phil Haack that suggested that nuget pack needed the -Build parameter to have nuget build the project so that it could include the project output. (Not sure how relevant that answer is, because TC is building the project and copies all the output to the right place, according to the build log, it seems that nuget pack only adds the main dll, and not the referenced dll)

Is this something that TC can support? Or do we need to build the package using a .nuspec file rather than a .csproj?



Comment actions Permalink


Yes, there is an issue with NuGet Pack runner.
The right way to solve it is to add -Build parametes (as you wrote), but in TeamCity case I would not have recommended that.

The proper (in terms of logging) way is to add an MSBuild/Sln runner build step to build solution beforehand.
And thus use NuGet Pack runner as the next step.

You sould also note, that you put same parameters in NuGet 'Properties' section as used in MSBuild, i.e.
Configuration or Platform. NuGet uses MSBuild to infer paths from the model and thus you should specify the same configuration
as you used to run the build.

Comment actions Permalink

Hi Eugene

Thanks for the information, our build configuration includes a sln build runner step then the nuget pack runner step. As far as I can tell the properties match, other than the sln runner builds the solution (there is only a single project in it), and the pack runner packs the csproj file.

Sln Runner Settings:

Nuget Pack runner settings:

This configuration does not pick up the project references and include them in the package.

I had to create a .nuspec file and add a <files> element to copy the files to the lib folder of the package before it would pick them up.

Should it pick the references up with the configuration we have?


Comment actions Permalink


As far as I know this configuration should work.
What TeamCity does is to simply start NuGet.exe pack command.

It seems there is a NuGet issue with dependency resolution here.

Probaby, behaviour depends on 'Local Copy' attribute of those libraries.

Still, having a .nuspec files seems to be a good workaround.


Please sign in to leave a comment.