Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

nuget

teamcity

I am trying to create a nuget package for a .csproj file but want the package name to be different from the csroj file (which it is by default) and I don't want to specify a .nuspec file. Is there a way of doing this? I can only see a version name override option on the command line options and not a package name override option.

I am doing this in TeamCity but this is besides the point. I am thinking I need to pass additional parameters to the NuGet pack command?

Thanks,

like image 233
Lee Englestone Avatar asked Oct 08 '14 08:10

Lee Englestone


People also ask

What is the use of Nuspec file?

A . nuspec file is an XML manifest that contains package metadata. This manifest is used both to build the package and to provide information to consumers. The manifest is always included in a package.

What is a Nupkg file?

Put simply, a NuGet package is a single ZIP file with the . nupkg extension that contains compiled code (DLLs), other files related to that code, and a descriptive manifest that includes information like the package's version number.


1 Answers

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$.

like image 192
STW Avatar answered Sep 21 '22 15:09

STW