Subdirectories are not copied by the file system provider
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
- Create a ASP.NET Core Razor page project
- Install Node.js
- Run
npm install bootstrap - Run
dotnet add package Microsoft.Web.LibraryManager.Build - Create a file named
libman.jsonwith the content below:
{
"version": "1.0",
"libraries": [
{
"provider": "filesystem",
"library": "node_modules/bootstrap/dist",
"destination": "wwwroot/lib/bootstrap"
}
]
}
- Run
dotnet build - 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
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
recurseto explicitly toggle this behavior. This is quite intuitive, but not very flexible. - add a separate
subdirectoriesproperty, maybe? - more flexible, but perhaps not very user-friendly (and making 'files' misnamed): enhance
fileswith 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" ].
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/"
}
@jimmylewis Is there any update?
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?
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
@jimmylewis filesystem provider still doesn't handle recursive cases.