I’m creating a component using .NET 8 MAUI for my application. In this component, I have some images in SVG format marked as MAUI Image
.
I created in the same solution a demo project to test my component. I added the component as a project reference
<ItemGroup>
<ProjectReference Include="..srcPSC.Maui.Components.LanguageDropdown.csproj"/>
</ItemGroup>
In the demo project, I can use the images from the component. Then I created the NuGet package for it.
If I create a new project and add the NuGet package, all the images will not be displayed anymore. I thought the component shared the images also with the project.
How can I allow other projects to access and use the images?
Update
I saw on GitHub a possible solution but it is not working for me.
I created a new file called PSC.Maui.Components.LanguageDropdown.targets
and I added those lines (and all the long list of images)
<Project>
<ItemGroup>
<MauiImage Include="$(MSBuildThisFileDirectory)ImagesFlagsf_ad.svg" />
</ItemGroup>
</Project>
Then, I edit the project file (.csproj
) and I added the file above
<ItemGroup>
<None Include="PSC.Maui.Components.LanguageDropdown.targets"
Pack="True" PackagePath="buildTransitive" />
</ItemGroup>
and then change this line
<MauiImage Include="ResourcesImagesFlagsf_ad.svg" />
into to this one
<MauiImage Pack="True" PackagePath="buildTransitiveImagesFlags"
Include="ResourcesImagesFlagsf_ad.svg" />
When I added the NuGet in a project, I get this error
Unable to find background file: C:Usersenric.nugetpackagespsc.maui.components.languagedropdown8.0.15buildTransitiveImagesFlagsf_ad.svg LanguageDropdownDemo (net8.0-android), LanguageDropdownDemo (net8.0-windows10.0.19041.0) C:Usersenric.nugetpackagesmicrosoft.maui.resizetizer8.0.82buildTransitiveMicrosoft.Maui.Resizetizer.After.targets 624
Update/2
I checked the NuGet package itself and I can see this
The package contains only the dll. So, I don’t know if it has to have a folder with all the images or the images are embedded in the dll.
9