.env in .NET
Load environment variables from the file
using dotenv.net; DotEnv.Load();
Include the file in the publish directory. (in case it’s not only used for local debugging)
<Content Include=".env" CopyToPublishDirectory="Always"/>
Add .env to .gitignore.