-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 publish: AppContext.BaseDirectory doesn't point to apphost directory #3704
Comments
@swaroop-sridhar is there any other path at the moment that points to the app host directory and/or name? |
In the current version, we simply extract the contents of the bundle to a directory on the disk, and declare that directory as the base-directory. This choice aims to preserve compatibility for apps that assume that apcontext.basedirectory contains the app.dll. In the current version, we'll need to use native APIs such as GetModuleFileName to get the path of the native AppHost. In subsequent versions, once the app.dll is processed directly from the bundle, the design doc discusses options to set |
You could also try using: |
That works, thanks! Is this (esp. |
Yes @dasMulli the value of |
Can make |
FYI seems like starting with .NET SDK 3.1.201, the with .NET SDK 3.1.101: in .NET SDK 3.1.201: let baseDir =
#if DEBUG
AppContext.BaseDirectory
#else
Diagnostics.Process.GetCurrentProcess().MainModule.FileName
|> IO.Path.GetDirectoryName
#endif |
@theimowski are you running this on macOS? In order to comply with notarization requirements, the signed binary ( You can get the old behavior again by specifying this in your project file: <PropertyGroup>
<UseAppHost>true</UseAppHost>
</PropertyGroup> See https://docs.microsoft.com/en-us/dotnet/core/install/macos-notarization-issues for more details |
Thanks @dasMulli yup I'm running on macOS and missed the notarization update. The |
Tagging subscribers to this area: @swaroop-sridhar |
This issue is fixed in .net5 |
Steps to reproduce
Publish self contained -
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=True --self-contained false
(or self-contained)Run the resulting exe file.
Expected behavior
According to the design document,
AppContext.BaseDirectory
is the API that developers should use to access the path where the app host resides.The app context base directory should therefore not be in
AppData\Local\Temp\.net\
.Background: I want to use this directory to load override config files.
Actual behavior
Environment data
cc @vitek-karas
The text was updated successfully, but these errors were encountered: