MSDeploy setParameter不起作用 [英] MSDeploy setParameter not working

查看:100
本文介绍了MSDeploy setParameter不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在构建部署系统中集成一次构建,随处部署"模型.

We are trying to integrate a 'build once, deploy anywhere' model in our build-deploy system.

MSDeploy为此提供了奇迹,它通过CRC校验和比较显着减少了构建时间,并且(大部分)在根据环境使用参数化更改应用程序web.config时,效果也一样好我们部署到.

MSDeploy works wonders for this, cutting down build time dramatically with CRC checksum comparisons and (for the most part) it works just as well when using parameterisation to change applications web.configs depending on the environment we deploy to.

我牢记了大多数这些参数,但是无论我在parameters.xml文件中用多少种不同的方式称呼,某些元素和属性从未改变似乎都没有改变.我已经概述了三个示例,这是我要更改的web.config文件:

I have the majority of these parameters nailed down, but a few elements and attributes never seem to change, no matter how many different ways I call them in the parameters.xml file. I have outlined three examples of this, here is the web.config file I am trying to 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>

这是parameters.xml文件:

Here is the 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>

这是对应的setParameters.xml文件:

And here is the 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"/>

我已经测试了每个XPath表达式,其结果与任何其他工作参数完全相同,但是以上似乎从未改变.

I have tested each XPath expression and the results are the exact same as any of the other working parameters, but the above never seem to change.

有人看到我在这里想念的东西吗?

Does anyone see anything obvious I'm missing here?

推荐答案

service_Address

我在这里找到了这个问题的答案:

service_Address

I found the answer to this problem here:

用MSDeploy替换web.config元素

我在XPath表达式的末尾缺少'text()',正确的XPath是:

I was missing 'text()' at the end of the XPath expression, the correct XPath is:

/configuration/applicationSettings/aim.Web.Properties.Settings/setting[@name='ai‌​m_Web_AddressService_Address']/value/text()


对于customErrorsMode问题,我在XPath表达式的开头缺少一个'/'.正确的表达式是:

For the customErrorsMode problem, I was missing a '/' at the start of my XPath expression. The correct expression is:

/configuration/system.web/customErrors/@mode  


这是我真正想到的,这是我发现的最后一个.经过一番挖掘后,我发现MSDeploy会自动对某些元素进行参数化,其中连接字符串就是其中之一,更多信息请参见:

This one really got to me, it was the last one I figured out. After doing a bit of digging I found out that MSDeploy automatically parameterizes certain elements, connection string being one of them, more info here:

配置Web程序包部署的参数

有关连接字符串的参数声明应为:

My parameter declaration for the 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>

我的setParameter定义应该看起来像这样:

My setParameter definition should have looked like this:

<setParameter name="DbConnectionString-Web.config Connection String" value="Data Source=dbserver;Initial Catalog=DB1;Trusted_Connection=no;User ID=user1;Password=pass*9;" />

这篇关于MSDeploy setParameter不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆