Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuget pack content files only

Tags:

package

nuget

I'd like to create a nuget package (from some c# project), but I don't want to embed the generated dll, but just some static files instead.

I added a tag at the end of my nuspec file, but nuget pack command continues to embed the project.dll in the package. The thing is I don't want this dll to be published.

Is there any way to do that?

Thanks,

Régis

like image 994
Regis Portalez Avatar asked May 29 '15 16:05

Regis Portalez


People also ask

How do I get files from a NuGet package?

on the toolbar of the Assembly Explorer window or choose File | Open from NuGet Packages Cache in the main menu . This will open the Open from NuGet Packages Cache dialog. The dialog lists packages from all NuGet cache locations on your machine. Use the search field in the dialog to find the desired package.

What are Nuspec files?

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.


2 Answers

Yes. You can create a .nuspec file that simply references the content files.

You must use nuget pack MyPackage.nuspec

Don't pack the .csproj file as that causes NuGet to include the built assembly.

See http://docs.nuget.org/create/nuspec reference for more info.

like image 116
Kiliman Avatar answered Sep 24 '22 05:09

Kiliman


To package a file as content, you must use target=content when listing the file in your .nuspec document.

To create a 'content only' nuget package, you must use a <files> node to list the files.

A <files> node must be a sibling of the <metadata> node.

A <file> node must be a child of a <files> node.

To include a file as content, set the target attribute in a <file> node to 'content'.

Example:

  <files>
    <file src="{filePath}" target="content"/>
  </files>

As previously mentioned, you must then pack the .nuspec file rather than a .csproj file:

nuget pack *.nuspec

I found the target=content trick here:

https://docs.microsoft.com/en-us/nuget/reference/nuspec#including-content-files

like image 38
Philip Raath Avatar answered Sep 24 '22 05:09

Philip Raath