dbFullSql和web.config的MSDeploy连接字符串

时间:2012-02-08 11:00:49

标签: msdeploy

我有一个(目前)相当简单的网站清单

<sitemanifest>
<IisApp path="c:\pathtosite" />
<dbFullSql path="Data Source=.\SQLEXPRESS;Initial Catalog=table;User Id=user;Password=pwd" includeIfNotExists="true" includeData="false" transacted="true" />
</sitemanifest>

通过IIS7.5导入站点时,dbFullSql提供程序会导致连接字符串的prom。我想重用提供的信息来更新web.config连接字符串,但不知道如何实现这个

1 个答案:

答案 0 :(得分:2)

听起来你想对我使用参数......当你在IIS inetmgr UI中导入一个包时,会为每个提供者创建默认参数,这就是你得到连接字符串提示的原因。但是,您也可以在创建包时添加显式参数。如果您使用msdeploy.exe cmd行执行此操作,则可以将参数放在文件中,然后将-declareParamFile:添加到package命令中以添加它们。数据库的参数可能是这样的 - 这表示使用提供的连接字符串作为dbFullSql提供程序路径并替换web.config的connectionStrings部分中的任何内容:

<parameter name="ConnectionString" description="Connection string for my database" defaultValue="Data Source=.\SQLExpress;Initial Catalog=table;User Id=user;Password=pwd" >
    <parameterEntry type="ProviderPath" scope="dbfullsql" match="Data\ Source=" />
    <parameterEntry type="XmlFile" scope="\\web.config$" match="//connectionStrings/add/@connectionString" />
</parameter>

此处有更多参数示例/资源: http://learn.iis.net/page.aspx/722/reference-for-the-web-application-package/http://technet.microsoft.com/en-us/library/dd569084(v=WS.10).aspx

如果您有其他Web Deploy问题,请在IIS.net上试用我们的论坛(http://forums.iis.net/1144.aspx)。

相关问题