Web.config using web deploy

Dave Mateer's Avatar

Dave Mateer

11 Mar, 2015 04:19 PM


How to get my web.config connection string transformed into the production values on Azure without using a web.release.config. I suspect I'm missing something simple.

I have a test ASP.NET MVC project: https://github.com/djhmateer/WebApplication3

building fine, then auto deploying from AppVeyor using Web Deploy to Azure:


Have got an Environment variable in AppVeyor of:
DefaultConnection - testConnectionStuff

parameters.xml in my source is:
  <parameter name="DefaultConnection">
    <parameterEntry match="/configuration/connectionStrings/add[@name='DefaultConnection']/@connectionString" scope="\\web.config$" kind="XmlFile"/>

parameters.xml artifact is:

  <parameter name="IIS Web Application Name" defaultValue="Default Web Site/WebApplication3_deploy" tags="IisApp">
    <parameterEntry kind="ProviderPath" scope="IisApp" match="^C:\\projects\\webapplication3\\WebApplication3\\obj\\Debug\\Package\\PackageTmp$" />
    <parameterEntry kind="ProviderPath" scope="setAcl" match="^C:\\projects\\webapplication3\\WebApplication3\\obj\\Debug\\Package\\PackageTmp$" />
  <parameter name="DefaultConnection" defaultValue="">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']/@connectionString" />
  <parameter name="DefaultConnection-Web.config Connection String" description="DefaultConnection Connection String used in web.config by the application to access the database." defaultValue="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20150311112537.mdf;Initial Catalog=aspnet-WebApplication3-20150311112537;Integrated Security=True" tags="SqlConnectionString">
    <parameterEntry kind="XmlFile" scope="C:\\projects\\webapplication3\\WebApplication3\\obj\\Debug\\Package\\PackageTmp\\Web\.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']/@connectionString" />

I was expecting to see the web.config transformed on Azure... or do I need to put in some code to look at Environment variable?


  1. Support Staff 1 Posted by Feodor Fitsner on 11 Mar, 2015 04:30 PM

    Feodor Fitsner's Avatar

    At a glance - parameters.xml is not included in the project and thus ignored during packaging: https://github.com/djhmateer/WebApplication3/blob/master/WebApplica...

  2. 2 Posted by Dave Mateer on 11 Mar, 2015 04:56 PM

    Dave Mateer's Avatar

    Thanks Feodor - good spot... Copy Always is now set! However, still no change

    not sure where in the console output the transformations should be.. have put a dump of the log here: http://www.programgood.net/files/output.txt


  3. Support Staff 3 Posted by Feodor Fitsner on 11 Mar, 2015 06:23 PM

    Feodor Fitsner's Avatar

    Try changing parameter's scope to scope="\\web\.config$" (with \ before dot).

  4. 4 Posted by Dave Mateer on 12 Mar, 2015 06:36 AM

    Dave Mateer's Avatar

    Ahh I've got it. From here: http://stackoverflow.com/questions/24428870/msdeploy-setparameter-not-working

    <parameter name="DefaultConnection-Web.config Connection String" defaultValue="">
      <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']" />

    And Environment variable name in Appveyor:

    DefaultConnection-Web.config Connection String

    A tricky one - thanks for you help

  5. Support Staff 5 Posted by Feodor Fitsner on 12 Mar, 2015 10:32 AM

    Feodor Fitsner's Avatar



  6. 6 Posted by Sebastian on 16 Dec, 2015 04:46 PM

    Sebastian's Avatar


    I'm having the same problem but haven't found a solution.

    I created a parameters.xml file in the root of my web project, with this content:

    <?xml version="1.0" encoding="utf-8" ?>
    <parameter name="DefaultConnection-Web.config Connection String" defaultValue="">
    <parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']" />

    In my appveyor.yml, I have an environment var set up:

        DefaultConnection-Web.config Connection String: xxx

    We are using cloud services however. I have no idea what I'm doing wrong, any suggestions?

  7. Support Staff 7 Posted by Feodor Fitsner on 16 Dec, 2015 06:25 PM

    Feodor Fitsner's Avatar

    parameters.xml doesn't work with Azure Cloud Services. Take a look at this blog post for how to use parameters in cloud services: https://blogs.endjin.com/2015/03/using-a-different-new-relic-applic...

  8. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac