14

I'm trying to copy a bunch of files from a specific folder into the root of a nuget package. Here's how it looks in my nuspec file:

<files>
  <file src="dist/product1/**/*.*" />
</files>

I want the files under dist/product1 be copied to root of nuget package but instead all files go to dist/product1 folder in nuget file, meaning it preserves the folder structure. I tried many variations. Any ideas?

Ali B
  • 626
  • 7
  • 20

1 Answers1

20

Using NuGet Package Explorer, I found out that I can use the following syntax.

<files>
  <file src="dist\product1\**\*.*" target="" />
</files>
Ali B
  • 626
  • 7
  • 20
  • 1
    To add a bit to this, years later. I've come across this while also looking to remove the parent directory and having the files added to the root directory. In my case it turned out to be due to the fact that I was using forward slashes rather than backward slashes. `dist/product1/**/*.*` should be `dist\product1\**\*.*` – ColinM Feb 15 '19 at 10:49
  • Yeah this is pretty bugged imho. Depending on which slashes are used and if there are wildcards or not and where those are, the output is quiet different. If you use wildcard prefixes like "**\bin\Release\MyLib.dll" it will preserve the subfolder. If you use normal slashes it also preserves it. This doesn't seem to be documented anywhere. But now I have at least a solution which is "no wildcards in path plus backslashes in src". – Robert S. Apr 26 '21 at 07:48