It is very easy to set environment variables per site on IIS Manager:
I looking for a way to do it using appcmd.exe so I can include this in my install script.
The closest I got was this:
C:\>C:\Windows\System32\inetsrv\appcmd.exe set config "dashboard" -section:system.webServer/aspNetCore /environmentVariables.[name='foo',value='bar'] /commit:apphost
-> dashboard is my site's name.
But this command returns this error:
ERROR ( message:Cannot find requested collection element. )