Skip to content

Self contained application does not start when the current directory is the application directory and current directory containing {appname}.runtimeconfig.json but does not contain {appname}.deps.json #64517

Description

@TalAloni

Description

I have a self-contained application without ".runtimeconfig.json" and without .deps.json.
I recently needed to start using ".runtimeconfig.json" (for the purpose of setting 'System.GC.Server').

The inclusion of the ".runtimeconfig.json" file changed the behavior of the (self-contained) application and now it can no longer be started when the current directory is the application directory.
I have to change the current directory in order for me to start the application.

After investigation, I have came across this in fx_muxer.cpp:

// Name of runtimeconfig file; since no path is included here the check is in the current working directory

return (deps_exists || !pal::file_exists(config_in_cwd)) && pal::file_exists(host_info.app_path) ? host_mode_t::apphost : host_mode_t::split_fx;

As can be seen, the presence of '{appname}.runtimeconfig.json' in the current directory, affect whether the self-contained application will be detected as a "standalone apphost" or "legacy split mode".

Reproduction Steps

  1. Create a Console application
  2. Set "GenerateRuntimeConfigurationFiles" and "GenerateDependencyFile" to false.
  3. Publish the application and set self-contained to true.
  4. Add a minimal {appname}.deps.json to the application directory containing just "{}".
  5. Attempt to launch the application when the current directory is the application directory.

Expected behavior

The application should launch successfully.

Actual behavior

The following message is displayed

Could not execute because the application was not found or a compatible .NET SDK
 is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application '/RUNASAPPLICATION' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET SDK from:
        https://aka.ms/dotnet-download

Regression?

No

Known Workarounds

Change the working directory

Configuration

Tested .NET Core 3.1 / .NET 5 / .NET 6.0.1

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Hostin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    Status
    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions