Skip to content

MRTCore using MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY breaks launching one WinAppSDK app from another #5987

Description

@DHowett

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.

Metadata

Metadata

Assignees

Labels

area-MRTCoreResourceManagerarea-WinAppSDKDeploymentIssues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged)

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions