I have been working on this problem for a while now and was not able to find a solution.
I have a Razor-Project, that has - among other files - a Stylesheet.razor
file. It looks like that:
<!-- FontAwesome stylesheets -->
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/UI.Web.Blazor.Components.css" />
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/assets/fontawesome/css/fontawesome.css" />
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/assets/fontawesome/css/duotone.css" />
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/assets/fontawesome/css/solid.css" />
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/assets/fontawesome/css/brands.css" />
<!-- Telerik scripts -->
<script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script>
<!-- Custom custom Telerik theme -->
<link rel="stylesheet" href="_content/UI.Web.Blazor.Components/telerik-ui.css" />
The files that are references here are all in the wwwroot
-Folder: For example the first href="_content/UI.Web.Blazor.Components/UI.Web.Blazor.Components.css"
-File can be found in wwwroot
Then I have a .nuspec
file in that same projekt:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>UI.Web.Blazor.Components</id>
<version>1</version>
<authors>Me</authors>
<description>A Blazor Component package</description>
<dependencies>
<group targetFramework="net8.0">
<dependency id="Microsoft.AspNetCore.Components.Web" version="8.0.0" />
<dependency id="Microsoft.Extensions.DependencyInjection" version="8.0.0" />
<dependency id="Microsoft.Extensions.Localization" version="6.0.7" />
<dependency id="Telerik.UI.for.Blazor" version="5.0.1" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\Release\net8.0\UI.Web.Blazor.Components.dll" target="lib\net8.0" />
</files>
</package>
I'm able to build the project and also pack it to a nuget package. So far so good.
But when I include this new package into my other project, where I want to consume it, I get 404-NotFound-Errors for all the files mentioned in the Stylesheet.razor
- except the script telerik-blazor.js
. That one is from another nuget package and they seem to do it right.
What am I doing wrong? I tried following nuspec changes:
contentFiles
-Tagfiles
-TagI've found the problem - it was the build pipeline in our company!
Background: We build the nuget packages automatically via pipeline and use the nuspec file to pack the project.
In my case, it was not practical to use the nuspec file to pack. I've changed it so that it will take the project file and that did the trick - all the files I needed were avaiable in the nuget package and my problems were solved :)
So: If you have the same problem just use dotnet pack
with the project file instead of the nuspec file.