I am deploying an IIS app on another machine using the "Deploy IIS App winrm" task.
This task deploys the zip file. In this zip there is an appsettings.json with variables preceding and ending with underscores.
I need to replace values in the appsettings.json for each environment. I tried putting the json file as "Web deploy parameter file" and "Overide parameters" but this doesn't work. How can I change the appsettings.json?
You don’t need to change appsettings.json. The core project can retrieve data from
appsettings.[environment].json
file per toASPNETCORE_ENVIRONMENT
environment variable.For example:
appsettings.[environment].json
files to project, such asappsettings.Production.json
,appsettings.Development.json
and set the corresponding value in each files.:
ASPNETCORE_ENVIRONMEN
T environment variable to each environment machine (just need to set/add once)There are some articles that can help you:
Configuration in ASP.NET Core
Working with multiple environments
If you still want to change appsettings.json file, you can unzip packaged file, then update file by using Token task (e.g. Replace Tokens), then zip these files.
More information, you can refer to Managing Config for .NET Core Web App Deployments with Tokenizer and ReplaceTokens Tasks