2

I have a nuget package in which I have an xml file, say, config.xml. I want this file to be copied to the bin folder of any dependent project. However, regardless of how I try to specify this file or where I put it based on various guides I've found, I can't manage to get it copied.

If I rename my .nupkg to *.nupkg.zip and look at it in explorer, it has the following internal structure:

package root
|-- lib
|    +-- net45
|          |-- My.Own.Library.dll
|          +-- My.Own.Library.xml
+-- config.xml

When I build the dependent project, I get something like this in my bin folder:

bin
|-- My.Own.Program.exe
|-- My.Own.Library.dll
+-- My.Own.Library.xml

Note that config.xml isn't included here. How do I, preferrably from the nuget specification of the package (rather than in the dependent project) make sure that config.xml is copied into the bin folder when the program is built?


Some additional info:

I have in the project.json file of the library which generates the nuget packge, the following specification:

"packInclude": {
  "/": "config.xml",
  "lib/net45/": "config.xml"
},
"contentFiles": [
  "config.xml"
],

However, this doesn't seem to generate anything in the .nuspec file that is included in the package in the output folder. I found these instructions, and edited the generated .nuspec manually to match:

<contentFiles>
  <files include="contentFiles/any/any/certificates.xml" copyToOutput="true" />
</contentFiles>

This didn't have any effect at all in the dependent project.

Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
  • Possible duplicate of [NuGet Package not copying XMLDoc file along with dll to bin](http://stackoverflow.com/questions/19136999/nuget-package-not-copying-xmldoc-file-along-with-dll-to-bin) – JEuvin Apr 25 '17 at 19:40

1 Answers1

-1

NuPack is an open source project under MIT licence that natively do what you need :

It is a nugget package that automatically create a package on build time. You can try it and see how it manage the feature you need.

It seems that it include a build folder in nuget package with a .targets file to include a post build process to copy with dependencies files.

Tony THONG
  • 772
  • 5
  • 11