LibraryManager icon indicating copy to clipboard operation
LibraryManager copied to clipboard

Subdirectories are not copied by the file system provider

Open FranklinWhale opened this issue 7 years ago • 6 comments

Functional impact

If libraries.library is specified without packages.files, it is expected all files and subdirectories are copied to the destination. Currently it is not the case, as only files are copied. As a result, all subdirectories of a library have to be listed as library in libman.json for them to be copied.

Minimal repro steps

Prerequisites: .NET Core SDK, Node.js

  1. Create a ASP.NET Core Razor page project
  2. Install Node.js
  3. Run npm install bootstrap
  4. Run dotnet add package Microsoft.Web.LibraryManager.Build
  5. Create a file named libman.json with the content below:
{
	"version": "1.0",
	"libraries": [
		{
			"provider": "filesystem",
			"library": "node_modules/bootstrap/dist",
			"destination": "wwwroot/lib/bootstrap"
		}
	]
}
  1. Run dotnet build
  2. Check the content inside wwwroot/lib/bootstrap

Expected result

All files and subdirectories under node_modules/bootstrap/dist are copied to wwwroot/lib/bootstrap

Actual result

Only the .DS_Store file, which is under node_modules/bootstrap/dist, is coped

FranklinWhale avatar Aug 10 '18 06:08 FranklinWhale

I stumbled upon this as well, but I wonder if this is by design. You can already cherrypick files to copy (though leaving that property out will implicitly copy all).

Possible approaches:

  • an additional boolean property recurse to explicitly toggle this behavior. This is quite intuitive, but not very flexible.
  • add a separate subdirectories property, maybe?
  • more flexible, but perhaps not very user-friendly (and making 'files' misnamed): enhance files with some glob-like syntax. Something like "files" : [ "**/*.*" ] would recurse. "files": [ "*.*" ], however, would only pick up files from the immediate directory. Moreover, this allows for more complex scenarios: "files": [ "*.css", "images/*.png" ].

chucker avatar Dec 12 '18 22:12 chucker

A year later...

You can't even cherry pick files not in the package root. Pretty useless!

This seems to work for me, though:

    {
      "library": "node_modules/datatables.net-bs4/css/",
      "destination": "wwwroot/lib/datatables.net-bs4/css/"
    },
    {
      "library": "node_modules/datatables.net-bs4/js/",
      "destination": "wwwroot/lib/datatables.net-bs4/js/"
    }

ronnieoverby avatar Dec 10 '19 18:12 ronnieoverby

@jimmylewis Is there any update?

Varorbc avatar Feb 07 '22 08:02 Varorbc

this issue is blocking. Using LibMan, we are unable to copy over all files (including sub-directories) into the destination. Is it still not fixed?

saravanansomu avatar May 17 '22 12:05 saravanansomu

We ran into this too. Is this just going to be ignored? This libman crap is primal. It doesn't even override files in the destination dir and I have to manually or do pre-build scripts to clean destination folder if files needs to be ovrridden because you update nuget pkgs

Porkechebure avatar Jul 06 '22 12:07 Porkechebure

@jimmylewis filesystem provider still doesn't handle recursive cases.

lawrence6140791 avatar Sep 23 '23 05:09 lawrence6140791