Describe the bug
WinAppSDK applications which use C# registration free WinRT set the environment variable MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY.
|
internal static void AccessWindowsAppSDK() |
|
{ |
|
// Set base directory env var for PublishSingleFile support (referenced by SxS redirection) |
|
Environment.SetEnvironmentVariable("MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY", AppContext.BaseDirectory); |
This environment variable is used by MRTCore to locate resources.
|
if (SUCCEEDED(wil::TryGetEnvironmentVariableW(L"MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY", baseDir)) && baseDir) |
When that env var is present, MRTCore skips all local resource PRI locations including ModuleName.pri and just loads resources.pri out of the specified directory.
|
searchStart = SearchPass::BaseDirForResourcesPri; |
This explodes any application that relies on resources when it is spawned from another WinAppSDK application using CreateProcess.
A word of advice: don't use Environment Variables to communicate information across your own processes. They get inherited in places you would not expect.
Describe the bug
WinAppSDK applications which use C# registration free WinRT set the environment variable
MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY.WindowsAppSDK/dev/UndockedRegFreeWinRT/UndockedRegFreeWinRT-AutoInitializer.cs
Lines 24 to 27 in bd8e2c1
This environment variable is used by MRTCore to locate resources.
WindowsAppSDK/dev/MRTCore/mrt/Core/src/MRM.cpp
Line 999 in bd8e2c1
When that env var is present, MRTCore skips all local resource PRI locations including
ModuleName.priand just loadsresources.priout of the specified directory.WindowsAppSDK/dev/MRTCore/mrt/Core/src/MRM.cpp
Line 1001 in bd8e2c1
This explodes any application that relies on resources when it is spawned from another WinAppSDK application using
CreateProcess.A word of advice: don't use Environment Variables to communicate information across your own processes. They get inherited in places you would not expect.