我正在尝试创建一个web.config转换文件,如果名称包含单词"Config",它将把appSettings值列表更改为"false".
<add name="Config.Showlog" value ="true" />
Run Code Online (Sandbox Code Playgroud)
转换文件有
<appSettings>
<add xdt:Transform="SetAttributes(value)"
value="false"
xdt:Locator="Condition(starts-with(@name,'Config')"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
Visual Studio 2010显示错误:
条件正好需要1个参数.
我也尝试使用Xpath作为xdt:定位器的属性并得到相同的错误.似乎问题来自VS 2010如何解析内部Condition()或表达式Xpath().
你怎么解决这个问题?
我需要在web.config中的多个WCF服务中切换出IP地址。使用web.config转换,除了通过xpath指定每个地址之外,还有什么方法可以创建搜索和替换语句。例如,将1.2.3.4的所有实例的IP地址1.2.3.4切换为4.3.2.1
我正在使用SlowCheetah for XML转换项目中的一堆配置文件.
但是,同样的解决方案是负载平衡设置的一部分,其中一些配置值在不同服务器之间不同(在这种情况下为两个).
我有以下构建配置
除了其中一个配置文件中的某些值外,Release.Prod1和Release.Prod2中的几乎所有内容都是相同的.有没有办法让我可以Something.Release.Prod.Config在这两个构建配置上使用一个文件,而不是有两个相同的文件(Something.Release.Prod1.Config和Something.Release.Prod2.Config)?
......并详细说明:在这种情况下,我正在部署到两个环境,因此一个重复的文件并不是一个巨大的危机.如果您有十台或一百台服务器怎么办?我认为没有理由为什么使用CI服务器(在这种情况下特别是TeamCity)的设置不应该这样做,即使我认为在这样的环境中更常见的自定义设置.
这通常如何处理?
我想我可以在实际转换发生前作为构建步骤来回做一些文件的魔术复制,但这似乎是一个混乱而过于复杂的解决方案.
configuration continuous-integration visual-studio web-config-transform slowcheetah
有没有办法根据子属性定位节点?或删除匹配节点的父节点?
我需要运行web.config转换来删除以下的第二个<dependentAssembly>:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- Don't want to delete this one -->
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<!-- This is the one I want to delete -->
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<codeBase version="11.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2011.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
查找<assemblyIdentity>很简单,但我需要删除父<dependentAssembly>(和<codeBase>).如果有一个"xdt:Transform ="RemoveParent"这将成功,但AFAIK没有.
或者,如果有一个Locator我可以在<dependentAssembly>上使用,它可以匹配孩子,那么这也可以.
我在我的web配置中有以下XML,我想使用web.config转换选择要删除的属性,但我想根据其中一个子元素的值选择要删除的元素.
我的web.config是这样的:
<configuration>
<sitecore>
<scheduling>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">core</param>
</agent>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">master</param>
</agent>
</scheduling>
</sitecore>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下尝试根据子元素选择第二个代理元素进行删除,<param desc="database">master</param>但没有成功.
<configuration>
<sitecore>
<scheduling>
<!-- Attempt 1 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="XPath(configuration/sitecore/scheduling/agent/param[text()='master'])"/>
<!-- Attempt 2 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove">
<param desc="database"
xdt:Locator="XPath([text()='master'])"/>
</agent>
</scheduling>
</sitecore>
</configuration>
Run Code Online (Sandbox Code Playgroud) 假设我有一个web.config下参数<appSettings><add key="myParam" value="myValue"/></appSettings>,我想修改的值myParam取决于发布配置文件我用,即DEVELOPMENT.pubxml和TEST.pubxml一个网站部署.
实现这一目标最直接的方法是什么?如何指定pubxml要转换的键,它们的位置等?
无论是直接回答还是回答此问题的资源链接都将受到高度赞赏.
publish web-config visual-studio web-config-transform webdeploy
我正在尝试删除Web.Release.config文件中的所有服务端点mexHttpBinding节点.我找到了这个答案 :(
我从我的代码文件中复制了,所以它实际上的格式与答案不同)
<services>
<service>
<endpoint binding="mexHttpBinding"
xdt:Locator="Match(binding)"
xdt:Transform="RemoveAll" />
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
我收到
的警告是在<service>节点上:
缺少必需的属性"名称".
我是否需要在节点的属性中添加空字符串或通配符(如果有)以解决此警告?
此外,上述转换不应该包含在节点中,还是不包含?name<service><system.serviceModel>
asp.net web-config-transform xml-document-transform web-release-config web-debug-config
我正在尝试设置web.config转换来修改某些值.我正在使用Octopus Deploy给出的这个例子:
http://docs.octopusdeploy.com/display/OD/Configuration+files
超薄版本的web.config:
<?xml version="1.0" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
变换:
<?xml version="1.0" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
输出:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<compilation debug="true" targetFramework="4.0">
</compilation>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我正在使用此工具预览转换:https: //webconfigtransformationtester.apphb.com/
你可以看到它没有做任何事情.我看了很多例子,但显然我错过了一些东西.任何帮助将不胜感激.
(我也试过没有运气):
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation debug="false" xdt:Transform="Replace">
</compilation >
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我似乎无法弄清楚你将如何改变以下内容
<configuration>
<location path="hello123">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
至
<configuration>
<location path="world321">
<.../>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
不删除第一个并添加第二个.对此的任何帮助都会很棒.
谢谢
如果我们需要将本地计算机连接到开发甚至生产数据库,我们将使用带有数据库连接字符串的本地配置文件。我们调用此文件ConnectionStrings.local.config并将其包含在我们的 C# 项目中,以便我们可以轻松编辑它。
我不希望在使用发布 Web 工具时包含此文件,因为我们将使用配置转换来替换每个服务器上真实数据源的连接字符串属性。
我修改了我的.csproj文件如下:
排除
但 ConnectionStrings.local.config 文件在发布后仍然显示在该文件夹中。
如何从部署中删除它而不从 Visual Studio 中排除该文件?