EDIT Actually I was wrong, I got a false diagnostic of my issue.
There were indeed a bug in .Net Core 3+ with SingleFile publishing with AppContext.BaseDirectory. But it is fixed now in .Net 5.
I saw it when enabling a primitive log system when my WPF is closing to debug the published application.
The mistake I made was using pack URI to access my content files.
This pack URI always work as a relative path from execution, so from the temporary extracted folder in case of SingleFile publishing, resulting in not finding the content file stored in AppContext.BaseDirectory.
So I had to remove using pack URI (Appending pack://application:,,, to the relative path) and use an absolute path (Path.Combine(AppContext.BaseDirectory,@MyContentFile)) instead.
For the record here was my question :
I have my WPF application that run. I have both ressource files and content files (some config and modifiable from user icons files).
When I publish it (via
dotnet publish) it work. But when I publish it as a single file (via-p:PublishSingleFile=trueparameter) then, as I understand here, The resulting application is silently extracted in a "random" temporary folder. So using my previouslyPath.Combine(AppContext.BaseDirectory,@MyContentFile)doesn't work asAppContext.BaseDirectorynow point to this temporary, unknown from me, folder.How can I get the path of my SingleFile, which is the root of my relative content files, at runtime, so from this unknown temporary extracted folder.
Thanks.