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

Single-file deploymentBug #1150

Open
Jlim01 opened this issue Jul 4, 2024 · 6 comments
Open

Single-file deploymentBug #1150

Jlim01 opened this issue Jul 4, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Jlim01
Copy link

Jlim01 commented Jul 4, 2024

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
<PropertyGroup> <InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces> </PropertyGroup>

@Jlim01 Jlim01 added the bug Something isn't working label Jul 4, 2024
@syntax-tm
Copy link
Contributor

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
Copy link
Author

Jlim01 commented Jul 7, 2024

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
Copy link
Contributor

Ctrl + F5 is start without debugging.

F5 is start debugging.

image

@MNDIA
Copy link

MNDIA commented Nov 11, 2024

The same reproduction from the latest stable version of the VS2022 community by expanding the newly created Compact Navigation template.
The problem is pinpointed to a null path for _host in App.xaml.cs of the template code
image
Non-null object, but empty string information
image
Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)! or Path.GetDirectoryName(AppContext.BaseDirectory)! should be used

@MNDIA
Copy link

MNDIA commented Nov 11, 2024

Expect the template to be fixed soon

@syntax-tm
Copy link
Contributor

Single file deployments cannot use the Location property (source). You can use AppContext.BaseDirectory instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants