-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Current executing assembly location is wrong for single file published project #13531
Comments
I'm not sure if this will work, but try using @jeffschwMSFT is this something you're familiar with? |
Ok. I`ll give it a try and share the results. |
It didn't work. It returns the same path as Location. |
The assermbly-location is the location of the main application DLL, which will be the temporary extraction directory. You can use something like: Or pinvoke into GetModuleFileNameW(Null, , ) |
This is a dup of https://github.com/dotnet/core-setup/issues/7491 |
Current executing assembly location is wrong when the project is published as a single file
General
I upgraded a .net core 2.2 application to 3.0 and I enabled the PublishSingleFile feature.
Unfortunately the current executing assembly location is not the directory where the executable is located. It is something like this:
This is how the single file publish feature is configured:
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishTrimmed>true</PublishTrimmed>
<OutputType>Exe</OutputType>
This is how I get the location of the current executing assembly:
var location = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
The text was updated successfully, but these errors were encountered: