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

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Jan 30, 2022
  2. vitek-karas commented on Jan 30, 2022

    @vitek-karas
    Member

    This is not really surprising, applications without .runtimeconfig.json are not really supported. I agree that this could/should probably be fixed, but I would strongly advise against removing .runtimeconfig.json. Similarly for .deps.json, the behavior without .deps.json is relatively well defined, but there are still potential issues.

    Just curious: Why did you decide to remove the .runtimeconfig.json (and the .deps.json) ?

  3. TalAloni commented on Jan 30, 2022

    @TalAloni
    ContributorAuthor

    Thanks, so just to be clear, I don't mind having .runtimeconfig.json but I wish to keep avoiding .deps.json.
    I found out that when .deps.json is present I am not able to dynamically load any pre-generated XmlSerializer DLL (generated using 'Microsoft.XmlSerializer.Generator').

    Once I removed .deps.json, this issue forced me to remove .runtimeconfig.json.

    It would be great to have this fixed as the current behavior is baffling at best.

  4. added this to the Future milestone on Jun 15, 2022
  5. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 15, 2022
  6. timo352 commented on May 7, 2024

    @timo352

    Commenting on this since we are running into similar problems at our organization on .NET 8.
    The "error" message displayed now is the dotnet help text instead of an actual error.

    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;

    The workarounds that we have found make the issue seem more like a bug than a legacy feature:

    1. Run from a different directory. Changing behavior based on cwd seems wrong.
    2. Call dotnet *.dll instead of calling *.exe directly. This requires having dotnet installed on the machine, partially defeating the purpose of self-contained apps.
    3. Move runtimeconfig.json to a different folder and provide the runtimeconfig <path> option

    For a few reasons [mainly the way that we deliver and support customized patches to previously deployed software] we do not want to rely on shipping the deps.json file. However, there are settings in runtimeconfig.json that are necessary for our application to work. We are able to get around it for now with workaround 2 with an IIS deployed application. We plan on adding support for Unix soon. In which case, we can't rely on workaround 2 since we will not want to install the dotnet runtime separately from our app.

    We'd gladly volunteer time to fixing it if we could get more details on what the "legacy split/fx mode" use case is. I'm not sure what existing behavior for .NET Core 1.x apps we need to avoid breaking. In my tests, this same workflow also fails for .NET Core 1.0 builds. Only running split_fx mode if the cwd is different from the application dir seems like a possibility.

  7. added
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 24, 2026
  8. locked and limited conversation to collaborators on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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