Issue
When using .UseJsonFile(), an exception is thrown when a setting is being written to a JSON file and the file does not exist. If the file already exists, the setting will be written correctly.
Workaround
We have reverted to Config.Json.Net/Config.Net 4.16.2, as this seems to work correctly.
Environment
.NET Framework 4.8
Affected Versions:
Config.Net 4.17.0
Config.Json.Net 4.17.0
Issue Reproduction
Create a .NET Framework 4.8 Console Application.
Install Config.Json.Net 4.17.0 NuGet package.
Write a new configuration builder using .UseJsonFile() with a relative/absolute path reference (example code below).
Assign a value to the setting property.
Example:
using Config.Net;
namespace JsonConfigStoreTest
{
public interface ISettings
{
string Setting { get; set; }
}
class Program
{
static void Main(string[] args)
{
ISettings settings = new ConfigurationBuilder<ISettings>()
.UseJsonFile("file.json")
.Build();
settings.Setting = "Test";
}
}
}
Issue When using .UseJsonFile(), an exception is thrown when a setting is being written to a JSON file and the file does not exist. If the file already exists, the setting will be written correctly.
Workaround
Environment
Affected Versions:
Issue Reproduction
Example: