I am working on a project, I am trying to transfer several libraries from the .NET Framework 4.5.2 to .NET Core 2, and I had some problems trying to read the deprecated app.config appsettings in unit tests.In order to reduce the problem to a minimal playback scenario, I created the following project in VS2017:

I have an app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="TestKey" value="20" />
</appSettings>
<configSections>
</configSections>
</configuration>
And the file UnitTest1.cs:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
namespace SimpleTestsUnits
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void FromConfigurationManager()
{
Assert.AreEqual("20", ConfigurationManager.AppSettings["TestKey"]);
}
}
}
And when you create this project, SimpleTestsUnits.dll is created, and SimpleTestsUnits.dll.config is created with the contents of the app.config file in the same folder of the SimpleTestsUnits.dll file.
So, when I run unit test using VS2017, the value of "TestKey" is always zero, and if I debug the configuration of ConfigurationManager.AppSettings, the key will not be loaded there.
: 'Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException' Microsoft.VisualStudio.TestPlatform.TestFramework.dll 'Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException' Microsoft.VisualStudio.TestPlatform.TestFramework.dll, Assert.AreEqual. : < 20 > . :. & ; () >
? ?