I need to set custom environment names for builds that gets deployed to different servers. From looking at official documentation and other answers elsewhere, the recommended option is to pass environment name as an argument while calling dotnet publish command. However the way pipeline is currently set such that the first stage is building the code and later when we get approval for release, we approve the deploy stage which copies the artificat and puts them in a folder which IIS is refering to for the API site.
Now that we need environment names, to avoid building for all environment in the first stage, we are planning to release to, we have to build again during deploy stage. i.e,. if we approve QA, we call dotnet publish with 'QA' as environment name and use that and if we approve LDT, then it builds the same code again with 'LDT" as environment name argument for dotnet publish command and so on. Nothing else change but the environment name. So if we decide to push a branch to dev,qa, stage and LDT, we end up building the same code 4 times.
I see that the publish command creates 'environmentVariable' tag to our web.config file. Is it enough that I update that manually after doing a default publish without any environment name or are there other approached?