I am working on a Blazor Component Library on .NET 8 within a corporation that contains many different officially designed and branded Components. Most work fine without flaw, but the Icon component is having issues finding the .svg files after being packed and consumed by another application via Nuget Package Manager.
When I reference the .csproj as a project reference and include the entire code base, it seems to find the files fine.
The files in question are .svg files. We have a collection of around 1000 files at wwwroot/images/icons that are all Blue. I’ve created a Python script that runs pre-build to generate other colors of icons. These other colors are placed into their own folders at wwwroot/images/icons_xxxxxx where xxxxxx is the hex color code of the icons.
In the Icon.razor.cs code, I have it referencing a hard-coded folder location of _content/ProjectName/images/icons + _xxxxxx/ with a small function to combine the file name onto the path as needed. It is worth mentioning that the Blue icons (the originals) are available within the Nuget package. It seems like the files generated by the pre-build step are not being included, but when I check the .nupkg file, all files are available under staticwebassets folder.
I’ve tried changing my hard-coded file path to look at staticwebassets instead of _content but to no affect.
Here I have my .csproj file which is being used in place of a .nuspec:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Configurations>Debug;Release;SkipIconPrebuildStep</Configurations>
</PropertyGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
<Content Remove="wwwrootcssmain.scss" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
<None Include="wwwrootcsscomponents_filter.scss" />
<None Include="wwwrootcssmain.scss" />
<None Include="wwwrootimagesicons**.svg" />
<None Include="wwwrootimagesSocial-Media*.*" />
</ItemGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
</ItemGroup>
<PropertyGroup>
<Description>This library contains officially branded and designed controls or Razor or Blazor front end projects.</Description>
<Authors>Software Team</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='SkipIconPrebuildStep|AnyCPU'">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>portable</DebugType>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(Configuration)'!='SkipIconPrebuildStep'">
<Exec Command="python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "14853D"
python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "C53532"
python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "956D00"
python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "767676"
python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "FFFFFF"
python "$(SolutionDir)scripts/UpsertIconColorFiles.py" "$(ProjectDir)wwwroot/images/icons/" "8096B2"" />
</Target>
</Project>