Search code examples
c#visual-studioweb.config-transform

Running with a different web.config locally in Visual Studio


We have a bug in a web site that, when running in dev, works just fine but when deployed to QA is causing failures. The software uses a lot of microservices and database connection strings that are a bit different in both environments though I have access to both from my local dev machine. We have different flavors of web.config to handle this.

So what I'd like to do is to run the software locally in visual studio but apply a different web.config file. I was going to just copy it over, but that isn't going to work because the web.qa.config are transforms rather than actual values.

So I figure it must be possible to do this, so I googled around but don't seem to be able to find anything explaining how to do this.

Any help would be appreciated.

I tried to copy the qa.config file over but that doesn't work because it is a transform. And I googled to find a solution, and didn't find one. (Note I know how to create new web.config variants which is what most articles were about, what I want to do is use an already existing web.*.config file but from my local machine where I can control it with breakpoints etc.)


Solution

  • You can change the environment under which you're running an app(thus changing configs to ones web._ENV_config. also):

    dotnet run --environment qa
    

    I would suggest reading up more on Documentation about multiple envs

    ++ just to be sure, go through your DevOps configs and look how it's starting for QA env and just execute the same command locally.