Is there an easy way to automatically create a NuGet package from a Visual Studio 2015 project?

Prior to Visual Studio 2015, it was trivial to configure your project to automatically create NuGet packages. In particular, you did:

  • Add .nuspec to the project.
  • Enable NuGet package recovery in the context menu of the Solution context menu
  • Edit the .csproj project file and set the build property <BuildPackage> to true

And it's all!

However, starting with VS 2015, MSBuild-integrated package recovery has been removed and replaced with a new automatic package recovery. Although this is all good news, it seems that setting the build <BuildPackage> to true no longer triggers the automatic build of packages.

This is a serious break in functionality! Is there a way to configure NuGet auto builds without using post-build events? In particular, I am looking for an MSBuild solution, as it is the basis of my build workflow.

+6
source share
4 answers

VS2015 has a transition to class library libraries, which makes creating NuGet packages incredibly easy. I have blogged about this before, but essentially these are just a few steps. Please note that this is only RC1 at the moment, not a stable release.

Class library package

  1. Add your code to the library and configure the project.json file with any changes you may need. A default The project.json file is used as an example.

  2. Right-click the project and select the Properties menu item. On the Assembly tab, select "Perform exits during assembly." Create a project.

Make a conclusion

You did. Go to the artifacts folder in your project, in my case "artifacts \ bin \ AwesomeSoft.TextConverter \ Debug".

You should see the already created NuGet package and the folders intended for each structure mentioned earlier.

Final nuspec

0
source

Try OctoPack: https://www.nuget.org/packages/OctoPack/

Just add the nuget package to your project.

If you want to build it every time you create a release, add the following line to the <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Whatever' "> section:

  <RunOctoPack>true</RunOctoPack> 

More information about finetuning can be found here: https://github.com/OctopusDeploy/OctoPack

+4
source

There is another alternative to NuPack:

How-to-create-a-nuget-package-on-each-Visual-Studio-with-NuPack

This is a nuget package that automatically generates a nuget package at build time.

0
source

VS4MAc already supports this, and you can get it as an extension for VS on Windows

https://github.com/NuGet/NuGet.Build.Packaging

0
source

All Articles