In Visual Studio 2022 access to the environment variables had changed from the previous version. The management of launch profiles has moved to a dedicated dialog. it may be accessed via a specific link. This link is Accessible under Project properties > Debug > General
The default vs 2022 environment variables are Production, Development, Staging.
To set environment variable in visual studio 2022:
From Solution Explorer Right click on your application and Select Properties from the menu.

From the new Window that appears click on Debug. Then click on link “Open debug launch profiles UI“

Environment variable convention in visual studio 2022
Variables are separated by a comma(,) and variables names and values are separated with an equal sign(=). In order to change the environment variable from development to production, let us write ASPNETCORE_ENVIRONMENT=Production.

Environment Variable On docker-compose file
To change the environment variable on docker-compose file click here.