【发布时间】:2010-07-06 21:28:07
【问题描述】:
我正在尝试在 Teamcity 服务器上使用 MSBUILD 更改我的 web.config 中的 connectionString。以前我在一个目标中使用了这个属性:
<PropertyGroup>
<UpdateWebConfigCode>
<![CDATA[
public static void ScriptMain()
{
XmlDocument wcXml = new XmlDocument();
wcXml.Load(@"TCM.MVC.UI\Web.config");
XmlElement root = wcXml.DocumentElement;
XmlNodeList connList = root.SelectNodes("//connectionStrings/add");
XmlElement elem;
foreach (XmlNode node in connList)
{
elem = (XmlElement)node;
switch (elem.GetAttribute("name"))
{
case "TCMBaseConnectionString":
elem.SetAttribute("connectionString", "Data Source=server-name;Initial Catalog=TCMCentral;User ID=user;Password=something");
break;
}
}
wcXml.Save(@"TCM.MVC.UI\Web.config");
}
]]>
</UpdateWebConfigCode>
然后我会在目标中调用它:
<Target Name="UpdateWebConfig">
<Script Language="C#" Code="$(UpdateWebConfigCode)" Imports="System.Xml" />
</Target>
但这一直抛出错误。我意识到这可能有点过时了,但找不到任何替代它的东西....有什么建议吗?
【问题讨论】: