Ran into this problem with VS2022, on one project but not another for some reason.
The solution boiled down to checking the appsettings file properties, and setting these two options: