Diego Santin
Diego Santin

Reputation: 71

NuGet pack for TFS Continuous Integration

I'm trying to make our TFS Build process to generate NuGet packages from our solution's projects. We aim to create a private package source, so all other internal products may download/update the framework using NuGet.

So far we've got the build process running (for a long time) and versioning our libraries, and the only thing that's left is to "nuget pack" all the projects.


What i have tryed so far:

  1. nuget spec *.csproj, then nuget pack *.nuspec;
  2. nuget spec *.dll, then nuget pack *.nuspec;
  3. nuget pack *.csproj directly (no .nuspec file);

All of them seem to work, but all of them seem to fail on the steps I actually need them to succeed.

What I actually get from doing the mentioned steps:

  1. No dependency¹ listed, no reference² listed;

  2. No dependency¹ listed, no reference² listed, all dlls from the directory are packed on the same .nupkg (whitout using -IncludeReferencedProjects);

  3. (The best so far) Some dependencies¹ listed, no reference² listed, only the actual project dll is inside the lib folder on the .nupkg.

¹: By dependency I mean NuGet dependencies, the packages from NuGet
²: By reference I mean solution project references.


Sample scenario:

Solution1.sln
-- ProjectA
-- ProjectB

ProjectA has a Project Reference to ProjectB. What I expect to happen on the .nuspec generated:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <id>ProjectA <- OK</id>
    <version>1.2.0.0 < - OK</version>
    <title>ProjectA <- OK</title>
    <authors>My Company <- OK</authors>
    <owners>My Company <- OK</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description</description>
    <copyright>OK</copyright>
    <dependencies>
        <dependecy id="ProjectB" Version="1.2.0.0" /> <<<<<<---- NOT HAPPENING!
    </dependencies>
  </metadata>
</package>    

Some nuget dependencies are listed, but not all of them (even when they are inside the packages.config from the refeered project). For example: I have a project that dependends on 4 other NuGet packages, only 2 are listed as dependencies on the generated .nuspec file.


Important information:


What I need:


Similar questions I've looked into:

NuGet: pack command is NOT including nuget dependencies
Nuget pack only including dependencies for some projects
Why doesn't nuget include the referenced project when packing?

Upvotes: 4

Views: 2003

Answers (2)

Diego Santin
Diego Santin

Reputation: 71

It turns out to be a simple path problem. The references and dependencies were not being properly added because I was executing the command from a different working directory.

On top of that, the use of -IncludeReferencedProjects was necessary to properly add everything needed.

After that the build process using Powershell completed successfully and everything is worked as expected =)

Upvotes: 3

Kevin
Kevin

Reputation: 429

The pack command has an option for including project references that must be specified: http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command_Options.

You'll need to target the csproj file, and I recommend creating a nuspec file manually.

Upvotes: 1

Related Questions