Search code examples
jenkinsautomationnuget-packagenuspec

Automated Nuspec Package Creation


Problem

So I am working on a feature to allow my team the ability to create NuGet Packages of specific projects automatically upon the project building successfully in Jenkins. I have spent the last 3 days researching how to contruct/create/build nuspec packages and NuGet packages... but nothing seems to point me in quite the same direction I am trying to take this in.

So far, from what I have learned and understood about creating NuGet packages, the primary way to do this is the following steps:

  1. Download nuget.exe and place a copy of it in the target project's root folder.

  2. Open the cmdprompt and navigate to the target project's root folder

  3. Run the following command nuget spec

  4. Open the newly created nuspect file and update all default values to the appropriate values for the target project

  5. Save the changes, then run the following command in the cmdprompt nuget pack packagename.nuspec

Although the above works as expect, it isn't really very automated.

I have taken an approach in which I created a script that has a nuspec template and populates fields, but I still require a lot of input from the user to make this happen.

Question

Is there any way to automatically generate a properly populated nuspec package for a target project that requires minimal input from a user?


Solution

  • There is a package on NuGet that

    • Works well in a continuous integration environment with a build server; and
    • Creates a nuspec file for your project.

    Source code with a larger readme is on Github