2

I created a new .net 6.0 MVC Web project and removed the preinstalled bootstrap from wwwroot/lib because I wanted to add it with NuGet Package Manager. After installing the package, files are shown as a reference in my wwwroot, and when I try to link them from code browser gives not found error cause they don't actually exists in my project.

Now I'm trying this: <link rel="stylesheet" href="~/css/bootstrap.min.css" /> but as I said is not working. The only solution I've got is to copy those file from C\..nuget\packages to my wwwroot but I've read that this reference is actually an intended behaviour from Microsoft, so it should be a way to use those referenced files but I can't seem to find it.

How should I reference those files in my code to be able to use them?

enter image description here

Also after copying files to project and running the project I get this error:

Severity Code Description Project File Line Suppression State Error Two assets found targeting the same path with incompatible asset kinds: 'C:\Users....nuget\packages\bootstrap\5.3.0\contentFiles\any\any\wwwroot\css\bootstrap-grid.css' with kind 'All' '...\Tickets\Tickets\wwwroot\css\bootstrap-grid.css' with kind 'All' for path 'css/bootstrap-grid.css' Tickets C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 419

I need to remove the package from manager to overcome this error...

sTx
  • 1,213
  • 13
  • 32
  • That's kind of expected..The contents of nuget files are copied to the destination, either automatically (dll files) or manually (most other files). They're never referenced directly in the package folder. – PMF Jul 13 '23 at 05:39
  • so it shouldn't be like that... – sTx Jul 18 '23 at 05:11
  • It's a bit uncommon to use this for html and css, but yes, it should be like that. You should copy the files from your package to your destination/project folder, not reference it there. – PMF Jul 18 '23 at 11:24
  • Can I suggest you use the Client Side library instead of the NuGet package? See https://stackoverflow.com/questions/68353885/how-to-install-and-use-the-latest-bootstrap-in-an-mvc5-project – JonPayne Jul 22 '23 at 21:07

0 Answers0