Set AppContext.BaseDirectory and the lookup path for AssemblyDirectory to the directory containing the NativeAOT module#112457
Conversation
…y to the directory containing the NativeAOT module
|
Could you add a test for this? I assume since this still doesn't build, it wasn't even manually tested to work, and we definitely don't have test coverage in the tree. |
|
Yes I need to still construct a test for this. I'll flip it to draft until I have it ready for review. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/AppContext.NativeAot.cs
Outdated
Show resolved
Hide resolved
|
@MichalStrehovsky I've added a test for this. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/AppContext.NativeAot.cs
Show resolved
Hide resolved
src/tests/nativeaot/SmokeTests/SharedLibraryDependencyLoading/SharedLibraryHost.cpp
Show resolved
Hide resolved
MichalStrehovsky
left a comment
There was a problem hiding this comment.
The tests are failing but it looks reasonable to me otherwise, thanks!
Just last week I was helping someone in the Windows org who was building a DLL and wondered why they can't load a JSON file next to the DLL with AppContext.BaseDirectory.
I wonder if we should doc this as a breaking change, someone might use this and it would be nice to have guidance ready (just use the directory of the Environment.ProcessPath).
|
I'll mark this as a breaking change and file the doc after I fix the test and merge. |
elinor-fung
left a comment
There was a problem hiding this comment.
It might also be good to add a note to the DllImportSearchPath.AssemblyDirectory doc about Native AOT libraries.
src/tests/nativeaot/SmokeTests/SharedLibraryDependencyLoading/SharedLibraryDependency.cpp
Show resolved
Hide resolved
src/tests/nativeaot/SmokeTests/SharedLibraryDependencyLoading/SharedLibraryDependencyLoading.cs
Show resolved
Hide resolved
…re relative to the current working directory.
|
Native AOT outerloop runs are broken: many tests failing with "The path must be absolute": If I'm reading this right the problem is that we somehow end up using the path of If this cannot be fixed quickly, I'd prefer this to be reverted because it's failing 100 tests and it's hard to keep an eye on outerloop with so many failures. |
|
I'll take a look today and if I can't fix it I'll revert it. |
📋 Breaking Change Documentation RequiredCreate a breaking change issue with AI-generated content Generated by Breaking Change Documentation Tool - 2025-10-03 13:48:57 |
|
We reverted this, so we don't need a doc for it. |
Fixes #112290
Fixes #90131
We already had most of the components needed to wire this up in the NativeAOT PAL and in the EH DeveloperExperience APIs, so this wasn't as bad as I thought.