Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After Update from 11.0 to 11.1.3 published app has runtime errors with double packed resources #16838

Closed
peter-friedland-t2i opened this issue Aug 28, 2024 · 9 comments · Fixed by #16835
Labels

Comments

@peter-friedland-t2i
Copy link

peter-friedland-t2i commented Aug 28, 2024

Describe the bug

I have updated our avalonia application from 11.0.11 to 11.1.3. The application builds and runs properly from IDE or dotnet run. But if I publish the app self contained for windows at runtime the following error occurs:

Avalonia.Markup.Xaml.XamlLoadException: No precompiled XAML found for HyperPlan.App2.App, make sure to specify x:Class and include your XAML file as AvaloniaResource
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Object obj)
   at HyperPlan.App2.App.Initialize() in C:\Users\peter.friedland\source\repos\HyperPlan-App\source\HyperPlan.App2\App.axaml.cs:line 11
   at Avalonia.AppBuilder.SetupUnsafe()
   at Avalonia.AppBuilder.Setup()
   at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action`1 lifetimeBuilder)
   at HyperPlan.App2.Program.Main(String[] args) in C:\Users\peter.friedland\source\repos\HyperPlan-App\source\HyperPlan.App2\Program.cs:line 12

To Reproduce

  1. Create new project with dotnet new avalonia.app -o MyApp
  2. Add <SelfContained>true</SelfContained> and <RuntimeIdentifiers>win-x64</RuntimeIdentifiers> to project file
  3. go to MyApp folder and run:
$ dotnet build
$ dotnet publish --configuration Debug --no-restore --no-build --output .\Publish --self-contained True --runtime win-x64
  1. Go to publish folder and start MyApp.exe

Won't start up, windows event log has an error with above mentioned exception

Expected behavior

App starts as intended

Avalonia version

11.1.3

OS

Windows

Additional context

Publish with removing the --no-build fixes the issue.

@kebox7
Copy link

kebox7 commented Aug 28, 2024

Hi, @peter-friedland-t2i.

Try adding the following to your project file. Maybe it will help.

<PropertyGroup>
  <AvaloniaIncludeApplicationIconAsWindowIcon>false</AvaloniaIncludeApplicationIconAsWindowIcon>
</PropertyGroup>

@peter-friedland-t2i
Copy link
Author

Hi, @peter-friedland-t2i.

Try adding the following to your project file. Maybe it will help.

<PropertyGroup>
  <AvaloniaIncludeApplicationIconAsWindowIcon>false</AvaloniaIncludeApplicationIconAsWindowIcon>
</PropertyGroup>

thank you for your help. I give it a try but I am not really sure that this will help guess you have been misslead by the name: Icons.axaml. its a resource dictionary containing geometrydrawings.

@kebox7
Copy link

kebox7 commented Aug 28, 2024

I am not really sure that this will help guess you have been misslead by the name:

Yes indeed, I was mistaken. I apologize. 😳

@AvaloniaUI AvaloniaUI deleted a comment Aug 28, 2024
@peter-friedland-t2i
Copy link
Author

I have some updates, I will add it in the description as well: when I create a new project outside of the solution it works., if I have the very same code in my existing solution the published app has the same problems. I am confused what outside of the project is responsible for that.

@peter-friedland-t2i
Copy link
Author

I found the real problem: when publish is perform with the flag --no-build the error also occurs for an empty, newly created project. I update the description.

@heuristicAL
Copy link

FYI I suspect that whatever causes your issue, also causes mine: #16732

@gbiellem
Copy link

gbiellem commented Aug 31, 2024

I hit the same problem. Thanks @peter-friedland-t2i for the tip about --no-build causing it. It got me unstuck for now

@gbtb
Copy link

gbtb commented Sep 5, 2024

Hi.
We also got hit by the same issue in NixOS/nixpkgs#331150 . Nixpkgs buildDotnetModule function separately calls dotnet build and then dotnet publish with --no-build flag. During our debug journey, I bisected Avalonia to the exact commit that breaks the build - #13840 .
We'd like to know Avalonia devs opinion on that matter - can we hope for a quick fix or should we adopt to the change and remove --no-build flag? Or maybe @TomEdwardsEnscape as an author of this change can provide another workaround?

@TomEdwardsEnscape
Copy link
Contributor

There is already a PR to fix this: #16835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants
@gbiellem @heuristicAL @peter-friedland-t2i @gbtb @kebox7 @TomEdwardsEnscape and others