Specifiying files in nuspec file doesn't suppress copying of other files

Topics: General
Jan 30, 2013 at 9:58 AM

I've got the following nuspec file:


<?xml version="1.0"?>
<package >
    <copyright>Copyright (c) 2012, me</copyright>
      <dependency id="SomeDep" version="[$version$]" />
    <file src="**\*.js" target="Content\Scripts" />



When I create a package with: 

NuGet.exe pack C:\somepath\myProj.csproj -OutputDirectory C:\Temp\NuGet-Cmd\Packages\ -Prop Configuration=Debug

I get a nupkg file with all the js files in the "Content\Scripts" folder. But also with a "Content\Controls" folder containing all the XML-Files that are part of the Project, and also the JS-Files that are originally in the Controls folder.

I thought that if I specify any files in the nuspec it will ignore the default content. At least it says so in the documentation under: http://docs.nuget.org/docs/reference/nuspec-reference#Specifying_Files_to_Include_in_the_Package

"Note that if you specify any files, the conventions are ignored and only the files listed in the .nuspec file are included in the package."


Is this a bug or am I doing something wrong?

If I leave the files element empty (I specify no file in it) there is nothing copied into the "content" folder of the package.

Feb 3, 2013 at 5:47 PM
Yeah, this is by design. The document is not clear; that sentence only applies when you build package against a .nuspec file rather than a project.
Jan 30, 2014 at 10:21 AM
I just found this post after having a similar issue with the documentation. It would be great if the documentation was updated. Also a possible feature suggestion is to add an attribute to the files element to specify whether you wish to override the conventions.