ASP.NET Core exception (the same key has been already added) when running under Linux

I have an ASP.NET Core API project. Previously I was able to successfully run it on Linux(ubuntu):

sudo dotnet Project.dll

I was also able to run it under Windows

Now something strange has been changed, I guess, and when I run the command:

sudo dotnet Project.dll

I am getting the exception:

Unhandled Exception: System.ArgumentException: An item with the same key has already been added. Key: environment
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Microsoft.Extensions.Configuration.Memory.MemoryConfigurationProvider..ctor(MemoryConfigurationSource source)
   at Microsoft.Extensions.Configuration.Memory.MemoryConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()

And then it points to the line

var host = new WebHostBuilder() 

in my Program.cs file, here it is:

public static void Main(string[] args)
    var config = new ConfigurationBuilder()
                    .AddJsonFile("host.json", optional: true)
                    .AddJsonFile("appsettings.json", optional: true)

    var host = new WebHostBuilder()


I have already rolled back Startup.cs to the point when it was successfully running but still getting this exception. At the same time I have no problem running this code under Windows. Please advise.