Home > Mobile >  WPF .NET Core 5.0 app - Publish to single file - not showing resources
WPF .NET Core 5.0 app - Publish to single file - not showing resources

Time:12-03

I saw in .NET 5.0 that you can publish app in single file which is something I was very keep to test and use for my app. My problem is that after I publish the app using the "Produce single file" option the .exe file generated does not include my resources.

enter image description here

First part is exe app from publish folder Second part is the exe app from build release folder

All the images are svg images with Build Action - Resource I also tried with Build Action - Embedded resource and Copy if newer, but I had no luck.

Any ideas how can I make my svg embedded into my exe file?

CodePudding user response:

Any ideas how can I make my svg embedded into my exe file?

Assuming you have set the Build Action of the image to Resource, it is included in the published application that is located in the bin\Release\net5.0-windows\publish\win-x86 or bin\Release\net5.0-windows\publish\win-x64 folder by default.

It's the .exe in this folder that is the single file app. You should not deploy the contents of the build folder.

CodePudding user response:

The problem was based on BionicCode the path of the ImageSource

I had to change the code from

      <RibbonButton x:Name="CoppyPageButton" Label="{x:Static p:Resources.Page_Copy_Button}" LargeImageSource="{svgc:SvgImage Resources/HomeTab/Clipboard/page_copy.svg}"></RibbonButton>

To

<RibbonButton x:Name="CoppyPageButton" Label="{x:Static p:Resources.Page_Copy_Button}" LargeImageSource="{svgc:SvgImage Source='pack://application:,,,/Resources/HomeTab/Clipboard/page_copy.svg'}"></RibbonButton>

Note that in order for the path to work it needed the single quotation marks.

  • Related