lepoco / wpfui

WPF UI provides the Fluent experience in your known and loved WPF framework. Intuitive design, themes, navigation and new immersive controls. All natively and effortlessly.
https://wpfui.lepo.co
MIT License
7.48k stars 725 forks source link

Single-file deploymentBug #1150

Open Jlim01 opened 3 months ago

Jlim01 commented 3 months ago

Describe the bug

I using Wpf UI - Compact Navigation template. but after i deploy single file in the visual studio , when I setup exefile, it couldn't execute. basic wpf app(without supporting WPFUI template) can execute. this is maybe bug.

(I followed that "https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=vs" this guideline for single file deployment)

To Reproduce

You should try this guideline [ https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=vs ]

and then execute your app

see Publish a single-file app(visual studio) part in the guideline

Expected behavior

publish ok, but can't execute program app on the publish folder path.

Screenshots

No response

OS version

window 11

.NET version

.net 8.0 win-x86

WPF-UI NuGet version

WPF-UI 3.0.3

Additional context

if you have issue when you publish, you can request help to chat gpt like it gave to me solution input into project's properties this `

$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration

`

syntax-tm commented 3 months ago

I build and publish as a single file app.

You have to set a few different things for MSBuild to actually produce a single file executable. Here is a link to the most recent Workflow run with the build artifact.

Jlim01 commented 3 months ago

I build and publish as a single file app.

You have to set a few different things for MSBuild to actually produce a single file executable. Here is a link to the most recent Workflow run with the build artifact.

thanks your reply and I will do your solution. Actually , I resolved that problem before through try ~ catch. I debugged and found basePath became null when execute exe file not in the visual studio's ctrl+f5. nomally in the vs when execute(ctrl+f5), That path is that my program path(Dbug / Release Mode path) . but I execute exe file, basePath is null. so I just add try catch since basePath is null so can't go next logic. but Im wondering basePath is important part for starting app. but why basePath is null, is continue with logic and no problem? Im just add try ~ catch. and not set basePath, it is status just 'null' from exceute program to exit program.

private static readonly IHost _host = Host.CreateDefaultBuilder() .ConfigureAppConfiguration(c => { var basePath = Path.GetDirectoryName(AppContext.BaseDirectory) ?? throw new DirectoryNotFoundException( "Unable to find the base directory of the application." ); _ = c.SetBasePath(basePath); }) .ConfigureServices( (context, services) => { // App Host ..... }

syntax-tm commented 3 months ago

Ctrl + F5 is start without debugging.

F5 is start debugging.

image