8000 `PublishSingleFile=true` support for desktop targets · Issue #20078 · unoplatform/uno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PublishSingleFile=true support for desktop targets #20078

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

Open
jstaro opened this issue Apr 26, 2025 · 0 comments
Open

PublishSingleFile=true support for desktop targets #20078

jstaro opened this issue Apr 26, 2025 · 0 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/enhancement New feature or request triage/untriaged Indicates an issue requires triaging or verification

Comments

@jstaro
Copy link
jstaro commented Apr 26, 2025

It's never clearly stated in docs that this is not supported, so I tried it out on Windows.

First place where it fails is here with a quite unhelpful error message which OOB in a new project I could only find in Event Viewer since it happens before any logger is set up.

Exception Info: System.InvalidOperationException: This operation is not supported for a relative URI.
   at System.Uri.get_LocalPath()
   at Uno.UI.Runtime.Skia.WpfHostBuilder.RegisterAssemblyResolver(Boolean useSharedFramework)
   at Uno.UI.Runtime.Skia.WpfHostBuilder..ctor()
   at Uno.UI.Runtime.Skia.HostBuilder.<>c__DisplayClass0_0.<UseWindows>b__0()
   at Uno.UI.Runtime.Skia.SkiaHostBuilder.Build()
   at unotest.Program.Main(String[] args) in C:\dev\uno\src\unotest\Platforms\Desktop\Program.cs:line 17

if (Uri.TryCreate(typeof(object).Assembly.Location, UriKind.RelativeOrAbsolute, out var uri))
{
// We expect that the path from System.Private.CoreLib.dll:
//
// file:///C:/Program Files/dotnet/shared/Microsoft.NETCore.App/8.0.2/System.Private.CoreLib.dll
//
// Will be the in a sibling folder from the Microsoft.WindowsDesktop.App using the same version.
// If the structure of the .NET installation changes, this code will need to be updated.
var version = Path.GetFileName(Path.GetDirectoryName(uri.LocalPath))!;
var dotnetShared = Path.Combine(Path.GetDirectoryName(uri.LocalPath)!, "..", "..");
_windowsDesktopFrameworkPath = useSharedFramework ?

This is because Assembly.Location always returns string.Empty w/ PublishSingleFile=true, but Uri.TryCreate returns true for an empty string for some reason so the code tries to access uri.LocalPath that subsequently throws.

Nowadays we should probably use RuntimeEnvironment.GetRuntimeDirectory() when we want to find the shared framework, and AppContext.BaseDirectory for when useSharedFramework is false (self-contained and single-file builds).

Then I started looking around and I see the code uses Assembly.Location in a lot of places.
That's totally fair.

So my suggestion for now is to mention the nonsupport in the docs and adjust the abovementioned code to give a more useful and instructive error message. Adjusting the code would make it more future-proof too, considering the comment there.

Then full support would have to be a larger feature up for consideration, I'm sure.

Why is this needed

Simplifies portable app distribution for (at least some) desktop platforms.

For which platform

Skia (WPF), Skia (Linux X11), Skia (macOS), Skia (Linux Framebuffer), Skia (GTK), Windows (WinAppSDK)

@jstaro jstaro added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/enhancement New feature or request triage/untriaged Indicates an issue requires triaging or verification labels Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/enhancement New feature or request triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

1 participant
0