Install-NuSpec & Enable-PackagePush: create, build & push NuGet packages anywhere

1 minute read

This short post is basically combining some of my recent posts (this one and that one) into one. Actually, into one single NuGet package :)

Basically, this one single package will allow me to automate and speed up package creation and publication, and it will run anywhere you can run the NuGet command line, because I only use nuget.exe and MSBuild to perform these actions. To set it up, I use a NuGet package (Install-Package NuSpec) and some PowerShell, but that's only to put the pieces of the puzzle in the right place, and give you some commands in Visual Studio. Once you're done, simply uninstall the package.

So, in short:

  1. Enable Package Restore to get the .nuget folder (which contains nuget.exe and some nuget.targets file I'll extend)
  2. Install-Package NuSpec (once per solution, target project doesn't matter)
  3. Install-NuSpec [-EnablePackageBuild]</strong> (for every project you want to trigger a package build)</li>
  4. Enable-PackagePush </strong> (for every project you want to enable auto-push)</li>
  5. Uninstall-Package NuSpec (once you're finished with steps 1-4 for the solution)
  6. </ol>
    A more detailed Readme is available on Github (where the sources are if you fancy some PowerShell).
    The package can be found on NuGet.

    If you're using MyGet already, you simply need to set the feedname and your own personal API-key in the NuGet.Extensions.targets file you'll find under the $(SolutionDir).nuget folder. If you're not using MyGet, simply replace the entire PushPkgSource and SymbolsPkgSource URLs by the one of your choosing.

Leave a Comment