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:
- nuget spec *.csproj, then nuget pack *.nuspec;
- nuget spec *.dll, then nuget pack *.nuspec;
- 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:
No dependency¹ listed, no reference² listed;
No dependency¹ listed, no reference² listed, all dlls from the directory are packed on the same .nupkg (whitout using -IncludeReferencedProjects);
(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:
- Every project has its own packages.config, the way NuGet builds it;
- The solution folder contains the packages folder, with all referenced packages;
- Already tryed Nugetter (XAML broken on VS 2012.3 and TFS 2012, cannot open it)
- Already tryed this, also does not include the dependencies and references properly;
- Solution package restore is turned ON (we need this to avoid storing the packages on TFS).
What I need:
- Automate the pack process to pack each csproj including all references and dependencies on the .nuspec file, so all of them will be properly loaded when installing it.
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?
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 =)
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.