xpath - MSDeploy setParameter not working -
we trying integrate 'build once, deploy anywhere' model in our build-deploy system.
msdeploy works wonders this, cutting downwards build time dramatically crc checksum comparisons , (for part) works when using parameterisation alter applications web.configs depending on environment deploy to.
i have bulk of these parameters nailed down, few elements , attributes never seem change, no matter how many different ways phone call them in parameters.xml file. have outlined 3 examples of this, here web.config file trying change:
<?xml version="1.0" encoding="utf-8"?> <configuration> <connectionstrings> <add name="dbconnectionstring" connectionstring="data source=null;initial catalog=null;trusted_connection=no;user id=user1;password=pass*9;" providername="system.data.sqlclient" /> </connectionstrings> <system.web> <customerrors mode="on" defaultredirect="/library/error/pagenotfound.aspx"> </customerrors> </system.web> <applicationsettings> <settings> <setting name="service_address" serializeas="string"> <value></value> </setting> <settings> </applicationsettings> </configuration>
here parameters.xml file:
<parameter name="dbconnectionstring" defaultvalue=""> <parameterentry kind="xmlfile" scope="\\web.config$" match="/configuration/connectionstrings/add[@name='dbconnectionstring']/@connectionstring" /> </parameter> <parameter name="customerrorsmode" defaultvalue=""> <parameterentry kind="xmlfile" scope="\\web.config$" match="configuration/system.web/customerrors/@mode" /> </parameter> <parameter name="service_address" defaultvalue=""> <parameterentry kind="xmlfile" scope="\\web.config$" match="/configuration/applicationsettings/aim.web.properties.settings/setting[@name='service_address']/value" /> </parameter>
and here corresponding setparameters.xml file:
<setparameter name="dbconnectionstring" value="data source=dbserver;initial catalog=db1;trusted_connection=no;user id=user1;password=pass*9;"/> <setparameter name="customerrorsmode" value="off"/> <setparameter name="service_address" value="https://myservice.asmx"/>
i have tested each xpath look , results exact same of other working parameters, above never seem change.
does see obvious i'm missing here?
service_address
i found reply problem here:
replace web.config elements msdeploy
i missing 'text()' @ end of xpath expression, right xpath is:
/configuration/applicationsettings/aim.web.properties.settings/setting[@name='aim_web_addressservice_address']/value/text()
customerrorsmode
for customerrorsmode problem, missing '/' @ start of xpath expression. right look is:
/configuration/system.web/customerrors/@mode
connectionstrings
this 1 got me, lastly 1 figured out. after doing bit of digging found out msdeploy automatically parameterizes elements, connection string beingness 1 of them, more info here:
configuring parameters web bundle deployment
my parameter declaration connection string in question should have been:
<parameter name="dbconnectionstring-web.config connection string" defaultvalue=""> <parameterentry kind="xmlfile" scope="\\web.config$" match="/configuration/connectionstrings/add[@name='dbconnectionstring']" /> </parameter>
my setparameter definition should have looked this:
<setparameter name="dbconnectionstring-web.config connection string" value="data source=dbserver;initial catalog=db1;trusted_connection=no;user id=user1;password=pass*9;" />
xpath web-config msdeploy webdeploy web.config-transform
No comments:
Post a Comment