Reputation: 4860
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
Upvotes: 9
Views: 9086
Reputation: 595
For contentFiles i use this way in the nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>DummyNuget</id>
<version>1.0.1-alpha</version>
<title>DummyNuget</title>
<authors>DummyNuget</authors>
<owners>DummyNuget</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>DummyNuget</description>
<releaseNotes></releaseNotes>
<copyright>2019</copyright>
<tags></tags>
<contentFiles>
<files include="**\*.*" buildAction="Content" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="<path to files>\*.*" target="contentFiles\any\any" />
</files>
</package>
files to put the local files in the nuget package then contentFiles in the metadata to put all the files in the project as content copy to output
Upvotes: 3
Reputation: 488
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://learn.microsoft.com/en-us/nuget/reference/nuspec#including-content-files
Upvotes: 5
Reputation: 20322
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.
Upvotes: 6