The configuration file 'appsettings.json' was not found and is not optional. The second sentence of the message, The expected physical path was '...', is the answer: the program looked in a folder that has no appsettings.json. In this test the base path was the current working folder, and the program was started from a different one. Point the base path at the program's own folder and copy the file there on build.

Two changes did it: SetBasePath(AppContext.BaseDirectory) in the code and CopyToOutputDirectory="PreserveNewest" for the file in the project. After that the program read the file when started from four different folders, the drive root among them.

The error

[cwd ...\cfg]
dotnet run --no-build --project Con1
Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was 'C:\...\fixes11\cfg\appsettings.json'.
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Program.<Main>$(String[] args) in C:\...\fixes11\cfg\Con1\Program.cs:line 3
exit=-532462766

The paths are shortened; nothing else changed. Starting Con1\bin\Debug\net10.0\Con1.exe from the same folder printed the same exception with the same expected path.

Why it happens

The program built its configuration like this:

using Microsoft.Extensions.Configuration;

var config = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json", optional: false)
    .Build();
...

Directory.GetCurrentDirectory() is the folder the shell was in, not the folder of the project or of the executable. Run inside the project folder, the same build printed Greeting: Hello from the fix11 test, because the file sat right there. Run from the parent folder, the expected path became ...\cfg\appsettings.json, which does not exist, and optional: false turned that into an exception at Build(). The project also had no item that copies the file to bin. A copy of the project with only the base path changed to AppContext.BaseDirectory showed that this alone is not enough:

dotnet run --no-build --project Con2
Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was 'C:\...\fixes11\cfg\Con2\bin\Debug\net10.0\appsettings.json'.
...
dir /b Con2\bin\Debug\net10.0\appsettings.json
File Not Found
exit=1

The fix

using Microsoft.Extensions.Configuration;

var config = new ConfigurationBuilder()
    .SetBasePath(AppContext.BaseDirectory)
    .AddJsonFile("appsettings.json", optional: false)
    .Build();
...
...
  <ItemGroup>
    <None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>

</Project>
[cwd ...\cfg]
dotnet build Con1 -v q -nologo

Build succeeded.
    0 Warning(s)
    0 Error(s)
...
dotnet run --no-build --project Con1
Greeting: Hello from the fix11 test
exit=0
Con1\bin\Debug\net10.0\Con1.exe
Greeting: Hello from the fix11 test
exit=0
dir /b Con1\bin\Debug\net10.0\appsettings.json
appsettings.json
exit=0

AppContext.BaseDirectory is the folder the program was loaded from, and the project item puts a copy of the file there on every build. Keep optional: false if the program cannot work without the file: the message then names the exact path it tried, which is what pointed at the cause here.

How it was reproduced

A console project from dotnet new console -f net10.0 with SDK 11.0.100 on Windows 11 and Microsoft.Extensions.Configuration.Json 10.0.14, an appsettings.json with one key in the project folder. The build was run with dotnet run in the project folder (it worked), then with dotnet run --project Con1 and the .exe from the parent folder (both failed), then again after the two changes, from the parent folder, the project folder, a sibling folder and C:\. A second copy, Con2, had only the base path changed. Every command shown without a PS> marker ran in cmd: a PowerShell script passed it as cmd /c ... 2>&1 and printed the exit= line after it.

Frequently asked

Why is appsettings.json not found when I run the exe from another folder?
If the code sets the base path to Directory.GetCurrentDirectory(), the file is looked for in the folder the program was started from. Use AppContext.BaseDirectory and copy the file to the output folder.
How do I copy appsettings.json to the bin folder in a console app?
Add a None item to an ItemGroup in the .csproj with Update set to appsettings.json and CopyToOutputDirectory set to PreserveNewest. In this test the file then sat next to the executable after the build.
Should AddJsonFile be optional true or false?
False when the program cannot run without the file, so a missing file stops it at start-up with the path it tried. True when the file only adds optional overrides.

More decoded errors in the Fixes category. If the file is found but its JSON is refused, see Failed to load configuration from file.