Search code examples
.netmodel-view-controllerpublishmsdeploy

With MSDeploy... how can you publish Web.QA.config => Web.config


This seems rather basic... but I cannot figure out how to do this... when I publish a Visual Studio project to my staging server (qa) I have a Web.QA.config file that contains all the transforms for database connections, etc... for my QA environment. I would have assumed the simple way would be to change something in my QA.pubxml file. Then if I right click my project and choose publish then QA... it would use use Web.QA.config as Web.config... any help?


Solution

  • By default, MSDeploy will apply the Web.{configuration}.config transformation file to the Web.config that matches the build configuration name.

    For simple projects, this means that the easiest way to apply environment-specific transformations is to rename the default build configurations "Debug" and "Release" to the name of your lowest and highest environments, then clone the lowest or highest environment configuration and name the clone(s) the middle environment name(s), if needed.

    From there you just need to ensure that your publish profile uses the matching build configuration.

    For more complicated projects, you might take a look at https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/transform-webconfig?view=aspnetcore-2.2. This is for aspnetcore, but the information contained is still applicable to .NET Framework.