have different configuration variable value on publish to production

71 views Asked by At

In Program.cs I read a configuration var like this:

var builder = WebApplication.CreateBuilder(args);
var host = builder.Configuration["host"]

In my development I need this var to be http://localhost/myapp

but when I publish (using VS2022 publish) to production I need it to be https://www.example.com

I tried creating multiple appsettings.json, .. appsettings.envName.json files, but when I publish they all get copied as is to the publish folder, regardless of what <EnvironmentName>envName</EnvironmentName> I have in the publish .pubxml file.

0

There are 0 answers