Reputation: 313
I'm working with asp.net core web app and trying to use libmam to manage client-side libs. I'm turn on "Enable Client-Side Libreries on Build" and write some code in libman.json:
{
"version": "1.0",
"defaultProvider": "cdnjs",
"defaultDestination": "wwwroot/lib",
"libraries": [
{
"library": "[email protected]",
"destination": "wwwroot/lib/jquery/"
}
]
}
Restoring libs works fine if I'm using "Restore Client-Side Libraries". But when I'm trying to build application I'm getting an error:"libman.json : error LIB002: The "[email protected]" library could not be resolved by the "cdnjs" provider".
How can I solve the problem?
Upvotes: 21
Views: 6914
Reputation: 6802
You can use another provider that has the version you need:
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"library": "[email protected]",
"destination": "wwwroot/lib/jquery/"
}
]
}
Upvotes: 1
Reputation: 734
Problem: While experimenting with eShopContainers using an outdated version, I encountered the same issue. Although it appears to be resolved in the current version, I'm sharing my solution in case others face the same problem.
Solution: To disable library restoration, add the following code to your .csproj file:
<PropertyGroup>
<LibraryRestore>false</LibraryRestore>
</PropertyGroup>
If you want to enable it only for the release version, add the following:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<LibraryRestore>true</LibraryRestore>
</PropertyGroup>
Now, the build should work smoothly. I'm currently exploring Docker functionalities with this setup, ensuring that my application builds successfully.
Reference: For more details, refer to the discussion on GitHub
Upvotes: 0
Reputation: 2292
So the reason, at least from what I've found, is that the library no longer exists or is not being seen by "cdnjs" provider.
The best way to deal with this is to update the library to a library that "cdnjs" does support. If you in fact already have the library installed consider using the "Disable libman" section.
The below instructions are being done on Visual Studio 2022, mileage may vary for other versions. If you have any issues consider using the "Re-add/Update" section.
Right click libman.json
click on Disable Client-Side Libraries on Build
In your libman.json
move your cursor over to the left most side of the file but to the right of the line numbers
A little light bulb should show up.
You'll be greeted with a couple of options, Click on Check for updates
(in my case I already have the latest version.)
Select the version you want and VS will autofill the version on that line.
<NameOfProject>.csproj
file)Add
-> Client-Side Library...
jquery@
, and then a dropdown list should appear allowing you to select the version you want.libman.json
file. Make sure to also delete the previous library if Visual Studio doesn't do that for you automatically.Upvotes: 11