Skip to content

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

@Cnicehs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Extensions-FileSystembughelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions