I recently needed to create a NuGet package from a project that had some dependencies on some other projects. Normally this isn’t a huge deal the following command would take care of it for you.
nuget pack pathToYourProject.csproj -IncludeReferencedProjects
The VSTS NuGet task with the pack command doesn’t currently provide to pass the include referenced projects flag. I had to jump through a few hoops to get this to work so I thought I would share.
The first step is to add the NuGet Tool Installer task, all the default settings work fine. Next, after the NuGet Tool Installer task add the Run Inline Powershell task. This task takes a bit more configuration. In the Script to run field enter the following.
$version = $buildBuildNumber.Substring($buildBuildNumber.IndexOf("_") + 1)
Invoke-Expression "nuget pack
-Properties Configuration=release -version $($version)
Then in the Arguments field enter the following.
If it hadn’t been for the version above which is based the Build Number the custom command type of the NuGet task would have worked fine.
Also published on Medium.