NuGet Pack: "An item with the same key has already been added."

May 27, 2011 at 12:54 PM

Hi,

I'm trying to add some other required dlls to my package, with this in the nuspec file:

 <files>
    <file src="..\..\Output\Debug\*.*" target="lib\net40" />
 </files> 

This fails when I call nuget pack, with the error "An item with the same key has already been added." If I change the target to "net4", all's ok and all the files that pack adds and these extra files are all referenced ok when I add this nupkg. This is a bit hacky though - shouldn't pack allow "net40"/any other duplicate key when specifying <file>s manually in the nuspec file, or am I doing something wrong?

Thanks,

Paul 

Oct 14, 2011 at 5:04 PM

Did you get this figured out? I have the same issue.

Oct 14, 2011 at 5:32 PM
Edited Oct 14, 2011 at 5:32 PM

I resolved this issue by changing my files section from

 

<files>
    <file src="..\..\Output\Debug\*.*" target="lib\net40" />
    <file src="..\..\Output\sl\Debug\*.*" target="lib\sl40" />
 </files> 

 

to

<files>
    <file src="..\..\Output\sl\Debug\*.*" target="lib\sl40" />
</files>

The net40 file tag isn't necessary since nuget pack Project.csproj includes the net40 output by default.