Skip to content

ConfigurationBuilder.AddJsonFile can't fire OnChange event using relative paths #71386

Closed

Description

@Cnicehs

Description

when using AddJsonFile("./api.json", true, true) it will not fire onChange event but using AddJsonFile("api.json", true, true) it will fire

Reproduction Steps

var builder = new ConfigurationBuilder();
ConfigBuilder = builder.AddJsonFile("./api.json", true, true).Build();
ChangeToken.OnChange(() => ConfigBuilder.GetReloadToken(), () =>
{
     Console.WriteLine("Reload");
});

Expected behavior

both "./api.json" and "api.json" can fire onChange event

Actual behavior

it seems like in PhysicalFilesWatcher.ReportChangeForMatchedEntries the _filePathTokenLookup save "./api.json" as key but try to match with "api.json"

Regression?

No response

Known Workarounds

No response

Configuration

.net6.0
Microsoft.Extensions.Hosting 7.0.0-preview.5.22301.12
Microsoft.Extensions.Primitives 7.0.0-preview.5.22301.12

Other information

No response

Activity

  1. ghost added
    untriaged
    on Jun 28, 2022
  2. added this to Runtime Infra and removed this from Runtime Infraon Jul 1, 2022
  3. removed
    untriaged
    on Jul 5, 2022
  4. added this to the Future milestone on Jul 5, 2022
  5. added
    help wanted
    on Jul 5, 2022
  6. added a commit that references this issue on Jul 12, 2022
    3789556
  7. ghost added
    in-pr
    on Jul 13, 2022
  8. ghost removed
    in-pr
    on Nov 8, 2022
  9. added
    in-pr
    on Jan 5, 2025
  10. added a commit that references this issue on Jan 15, 2026
    83d4dcd
  11. quixoticaxis commented on Jan 18, 2026

    @quixoticaxis
    Contributor

    Given that the relative parent path (..) does not work, does it make more sense to forbid relative paths all together?

  12. locked and limited conversation to collaborators on Feb 18, 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-Extensions-FileSystembughelp wantedin-pr

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions