Web.config using web deploy
Hi
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:
https://dwebapplication3.azurewebsites.net/
Have got an Environment variable in AppVeyor of:
DefaultConnection - testConnectionStuff
parameters.xml in my source is:
'<parameters>
<parameter name="DefaultConnection">
<parameterEntry match="/configuration/connectionStrings/add[@name='DefaultConnection']/@connectionString" scope="\\web.config$" kind="XmlFile"/>
</parameter>
</parameters>'
parameters.xml artifact is:
<parameters>
<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>
<parameter name="DefaultConnection" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']/@connectionString" />
</parameter>
<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" />
</parameter>
</parameters>
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?
http://www.appveyor.com/docs/deployment/web-deploy#web-deploy-parametrization
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | 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
Support Staff 1 Posted by Feodor Fitsner on 11 Mar, 2015 04:30 PM
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 Posted by Dave Mateer on 11 Mar, 2015 04:56 PM
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
https://ci.appveyor.com/project/djhmateer/webapplication3/settings/environment
Support Staff 3 Posted by Feodor Fitsner on 11 Mar, 2015 06:23 PM
Try changing parameter's scope to
scope="\\web\.config$"
(with\
before dot).4 Posted by Dave Mateer on 12 Mar, 2015 06:36 AM
Ahh I've got it. From here: http://stackoverflow.com/questions/24428870/msdeploy-setparameter-not-working
Parameters.xml
<parameter name="DefaultConnection-Web.config Connection String" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']" />
</parameter>
And Environment variable name in Appveyor:
DefaultConnection-Web.config Connection String
A tricky one - thanks for you help
Support Staff 5 Posted by Feodor Fitsner on 12 Mar, 2015 10:32 AM
Sure!
-Feodor
6 Posted by Sebastian on 16 Dec, 2015 04:46 PM
Hey,
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" ?>
<parameters>
<parameter name="DefaultConnection-Web.config Connection String" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='DefaultConnection']" />
</parameter>
</parameters>
In my appveyor.yml, I have an environment var set up:
environment:
DefaultConnection-Web.config Connection String: xxx
We are using cloud services however. I have no idea what I'm doing wrong, any suggestions?
Support Staff 7 Posted by Feodor Fitsner on 16 Dec, 2015 06:25 PM
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...Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.