Create a nuspec from csproj with GUI

GilliVilla picture GilliVilla · Aug 12, 2014 · Viewed 11.4k times · Source

I have a C# project which has a 2 Project References from projects within my Solution.

It also has 5 NuGet package references from packages in my NuGet repository. Given the .csproj, How can I generate or create the nuspec file using NuGet Project Explorer tool?

And how to validate if this nuspec is indeed correct?

Answer

Matt Ward picture Matt Ward · Aug 12, 2014

You can do this using NuGet.exe with the command line similar to:

NuGet.exe spec Project.csproj

To do this from within Visual Studio you could add a new External Tool (from the Tools menu) which uses NuGet.exe.

NuGet Project Explorer supports NuGet packages but not project files so one of the above techniques would be simpler. For the NuGet Project Explorer you would need to write a custom addin.

For validation, NuGet.exe will generate the .nuspec file so it should be valid. Also when you use NuGet.exe pack YourNuspec.nuspec it will be validated when you create a NuGet package with warnings output to the console.