KEMBAR78
single file publish: AppContext.BaseDirectory doesn't point to apphost directory · Issue #3704 · dotnet/runtime · GitHub
Skip to content

single file publish: AppContext.BaseDirectory doesn't point to apphost directory #3704

@dasMulli

Description

@dasMulli

Steps to reproduce

  1. Create a hello world program:
static void Main(string[] args)
{
    Console.WriteLine("Hello World!");
    Console.WriteLine($"Base Directory: {AppContext.BaseDirectory}");
    Console.WriteLine($"Assembly Location: {typeof(Program).Assembly.Location}");
}
  1. Publish self contained - dotnet publish -c Release -r win-x64 -p:PublishSingleFile=True --self-contained false (or self-contained)

  2. 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

C:\demos\testcons\bin\Release\netcoreapp3.0\win-x64\publish>testcons.exe
Hello World!
Base Directory: C:\Users\ullrimar\AppData\Local\Temp\.net\testcons\53kpwgv0.3mq\
Assembly Location: C:\Users\ullrimar\AppData\Local\Temp\.net\testcons\53kpwgv0.3mq\testcons.dll

Environment data

>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview7-012821
 Commit:    6348f1068a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview7-012821\

Host (useful for support):
  Version: 3.0.0-preview7-27912-14
  Commit:  4da6ee6450

cc @vitek-karas

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions