question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish app not rendering images.

See original GitHub issue

Description

Published app doesn’t render any images.

Steps to Reproduce

  1. Create new MAUI Project Visual studio creates one templated project with “Hello world text” + one image(dotnet_bot.svg) in center of window.
  2. Publish app using command open cmd > set path to project directory (cd <project-directory-path>) Run following command dotnet publish -f net7.0-windows10.0.19041.0 -c Release -p:WindowsPackageType=None -p:SelfContained=true -p:WindowsAppSDKSelfContained=true
  3. Open <project-directory-path>/bin/release/publish/YourProjectName.exe Observe image(dotnet_bot.svg) is not rendering in UI anywhere.

Link to public reproduction project repository

NA

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Captnwalker1commented, Mar 15, 2023

My workaround, a powershell script that runs via a afterPublish target:

#fixMauiPublishImages.ps1
param
(
	[Parameter(Mandatory=$true)][string]$StagingDir,	
	[Parameter(Mandatory=$true)][string]$OutputDir
)

#if maui ever fixes this issue, remove this script https://github.com/dotnet/maui/issues/10526

$OutputPath = "$OutputDir\Your.Project.Name"

#Copy only the files we want, but preserving directory structure
Write-Host "Copying file(s)..."
robocopy $StagingDir $OutputDir *.png *.ico *.html *.svg *.sql *.ttf *.otf /s /nfl /ndl

Write-Host "Done."

After Publish Target in csproj:

...
	<Target Name="CustomAfterPublish" AfterTargets="Publish;AfterPublish">
		<Exec Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Command="powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File &quot;$(ProjectDir)..\FixMauiPublishImages.ps1&quot; $(OutputPath) $(PublishDir)" />
	</Target>
...
0reactions
Captnwalker1commented, Apr 5, 2023

Also if you change your commandName in launchSettings.json from MSIXPackage to Project, the same happens. No images are in the bin directory.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Some of the images are not coming after Publishing WPF ...
I ran the application on the client PC and I noticed that some of my images are not appearing e.g. Background images of...
Read more >
Solved: Galleries not rendering properly after publishing
Solved: Hello, I am running into an issue where my galleries load just fine in the designer when I click Preview. However, when...
Read more >
Why my images are not showing when i deployed to ...
I deployed empty image folder, and the images are uploaded by the user which is visiting the site. Do the uploaded image not...
Read more >
How to Render Images in a React App | by Carlie Anglemire
I found using require() useful when I wanted to render an image dynamically instead of hard-coding the file path.
Read more >
Images not rendering | Optimizely Developer Community
The settings you have above only work for Azure publishing, not local. I have the following setting in my Web.Release.config which is used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found