title: Azure DevOps - Setting An Environment Variable on the Target Machine in a Deploy Group
body: <p>I am deploying an Asp.Net Core application via Azure DevOps' Pipelines option and trying to set an environment variable on each of the target machines. Each deployment environment has its own settings file (for example &quot;appsettings.Development.json&quot;) that the Asp.Net app chooses from when it starts up by reading the ASPNETCORE_ENVIRONMENT environment variable. I am using a Deploy Group to deploy the artifact to our on-site servers and that is working perfectly until it comes to setting the correct appsettings file to use.</p>
  <p>I tried unsuccessfully to use a PowerShell task that has this inline script:</p>
  <p><code>$Env:ASPNETCORE_ENVIRONMENT=&quot;$(EnvironmentName)&quot;</code></p>
  <p>All the pipeline tasks are executed successfully but the environment variable doesn't actually get applied on the target machine.</p>
  <p>How can I set an environment variable on the target machines in a Deploy Group?</p>