When using NuGet Pack is it possible to specify the package name without a nuspec file?

Nuget command line doesn't provide any option for direct name change. http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command

If you want to differ project and nuget package name you will have to prepare and edit custom nuspec file. You may also do it manually after creating package by using e.g. NuGetPackage Explorer.


From NuGet 4.0 it is now possible to specify package name and other metadata as properties in your .csproj file. See https://docs.microsoft.com/en-us/nuget/guides/create-net-standard-packages-vs2017 for more information.


Nuget's Properties argument is what you're looking for.

Provided your .nuspec file uses a placeholder then you can pass a value for it via the Properties argument. From the nuget docs:

Properties. Specifies a list of token=value pairs, separated by semicolons, where each occurrence of $token$ in the .nuspec file will be replaced with the given value. Values can be strings in quotation marks.

So nuget.exe -Properties id=someProject will use "someProject" for any occurance of $id$.

Tags:

C#

Teamcity

Nuget