I would like to be have multiple DB connection strings in my app.config file with the same server name. I am using SlowCheetah to perform transforms based on different configurations. Here is what I currently have, which works fine.
app.config contains:
<connectionStrings>
<add name="Catalog1String" connectionString="TO BE REPLACED" providerName="System.Data.SqlClient" />
<add name="Catalog2String" connectionString="TO BE REPLACED" providerName="System.Data.SqlClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
app.test-env.config contains:
<add name="Catalog1String" connectionString="Database=catalog1;Server=TestDbServer;Integrated Security=SSPI;Connection Timeout=60" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
<add name="Catalog2String" connectionString="Database=catalog2;Server=TestDbServer;Integrated Security=SSPI;Connection Timeout=60" xdt:Transform="Replace" xdt:Locator="Match(name)"/>
Run Code Online (Sandbox Code Playgroud)
This works fine, but when I have …
我正在尝试使用Slow Cheetah在本地数据库连接字符串和SQL Azure连接字符串之间切换.这是Azure工作者角色,我正在使用TeamCity推送到Azure.当我查看日志文件时,Slow Cheetah进程正在正常运行并且正在生成转换后的app.config,但未来的构建步骤(我认为我无法控制)是用原始app.config编写转换后的文件. .
有没有其他人用这种方法取得任何成功,或者你能指点我另一种方法来切换我的连接字符串.我被指向只使用一个连接字符串并编辑hosts文件指向我想要的数据库,但这看起来很混乱.
connection-string app-config azure azure-worker-roles slowcheetah
我正在使用SlowCheetah转换CI服务器上的Visual Studio Web项目中的XML配置文件.在Visual Studio 2010中,XML将在我发布时进行转换,但在CI服务器上不会发生转换.相反,我只是获得原始的非转换配置文件.我按照Sayed Ibrahim博客提供的说明进行了解释,他解释了在解决方案中添加SlowCheetah dll和targets文件并指向项目文件以使用这些文件.我做了这个改变,并在Visual Studio中发布了一个只是为了确保它有效并且确实有效.但是当我在CI服务器上构建项目时,我遇到了与以前相同的问题.
我的假设是它与我用于在CI服务器上构建项目的MSBuild脚本有关.我是否需要添加一些东西来告诉我的项目使用SlowCheetah?我的构建脚本如下:
<Project DefaultTargets="DoPublish"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SourceFileRootFolder>$(CCNetWorkingDirectory)\Code</SourceFileRootFolder>
<WebFolder>DCSIWeb\DCSIWeb</WebFolder>
<ReleaseFolder>C:\Builds\BuildFolder</ReleaseFolder>
</PropertyGroup>
<PropertyGroup Condition ="$(CCNetWorkingDirectory) == ''">
<SourceFileRootFolder>C:\Builds\ProjectWorkingDirectory\Code</SourceFileRootFolder>
<ReleaseFolder>C:\Builds\BuildFolder</ReleaseFolder>
</PropertyGroup>
<Target Name="CleanSource">
<Message Text="Removing all source files from $(ReleaseFolder)" />
<RemoveDir Directories="$(ReleaseFolder)" />
</Target>
<Target Name="DoPublish">
<CallTarget Targets="CleanSource"/>
<MSBuild Projects="$(SourceFileRootFolder)\DCSIWeb.sln" Targets="Clean;Build" />
<MSBuild Projects="$(SourceFileRootFolder)\$(WebFolder)\DCSIWeb.csproj"
Targets="_CopyWebApplication;_BuiltWebOutputGroupOutput;TransformWebConfig"
Properties="OutDir=$(ReleaseFolder)\" ></MSBuild>
</Target>
Run Code Online (Sandbox Code Playgroud)
MSBuild脚本基本上构建项目并将项目放入"c:\ Builds\BuildFolder".当我在构建完成后查看构建文件夹时,我看到了我需要的.config文件,但没有发生任何转换.这是以前的文件.
我使用SlowCheetah来转换我的app.configs.我有一个多项目解决方案,其中一个项目执行一个后期构建事件,其中bin的输出被复制到别处.我发现SlowCheetah在构建后事件之后进行了转换,因此我正在复制的app.config是预转换版本.
有没有人建议我在SlowCheetah转换后如何执行我的副本?这是否需要我编写自定义构建任务?
我正在使用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配置中有以下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) 我使用EF代码优先迁移:
https://msdn.microsoft.com/en-us/data/jj591621.aspx
add-migration
,update-database
等全部由包管理器控制台VS.叫
我还使用 SlowCheetah 来管理我们拥有的各种环境,特别是包括管理每个开发人员都有自己的数据库副本这一事实,以便他们可以更新他们的模型更改,而无需将其他人锁定在数据库之外。因此,更改的配置值之一是目标数据库名称。
(出于我不会介绍的原因,我们不使用connectionStrings
.config
此类设置,而是将 DB 名称放在appSettings
块中)
我的包含模型和迁移的TheCustomer.Database
项目是项目。
如果我手动更改 中的appSetting
值TheCustomer.Database/app.config
并运行迁移,它会正确使用配置值 - 所以配置基本上是有效的。
但是如果我设置一个 SlowCheetah 转换来修改给定构建配置的值,选择该配置,重建代码,然后运行迁移,那么它不会应用转换;它使用 base 中的值app.config
,而不是app.SelectBuildConfig.config
SlowCheetah 总体上运行良好 - 当我运行 sln 来获取网站时,它使用了由 VS Build Config 确定的正确 Db。
有什么想法吗?
编辑:
配置文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<appSettings>
<add key="DbName" value="This Default …
Run Code Online (Sandbox Code Playgroud) 这是我第一次将 SlowCheetah 用于 JSON 配置文件。我找不到让它转换数组设置的方法。例如,如果我的基本配置文件具有以下设置:
{
"Settings" : [1, 2, 3]
}
Run Code Online (Sandbox Code Playgroud)
我想把它转移到:
{
"Settings" : [4, 5, 6]
}
Run Code Online (Sandbox Code Playgroud)
它只是进行合并,而不是替换。有没有办法告诉它该怎么做?就像我们在 xml 配置文件中使用 xdt:Transform="Replace" 的方式一样。
我有一个带有Slow Cheetah'ed配置文件的类库项目.
在过去,很容易使用"添加为链接"将配置文件添加到其他项目.如何使用Slow Cheetah实现这一点,因为配置文件是动态的?
我需要某种配置文件的添加引用,或者如果没有办法这样做,我必须再次复制配置文件和Slow Cheetah.
我在Visual Studio 2013中有一个带有MVC 5和EF 6的.NET 4.5项目。我想要对app.config进行转换。
我已经通过NuGet安装了SlowCheetah项目,并且(应该是)[ https://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5]现在,我应该可以右键单击App.config并查看选项添加变换。但是我没有。
有谁知道这可能是什么原因?
我检查了该软件包是否已在我的解决方案的两个项目中安装,重新启动,重建等。
slowcheetah ×10
app-config ×4
msbuild ×2
web-config ×2
.net ×1
arrays ×1
asp.net ×1
azure ×1
c# ×1
config ×1
json ×1
xml ×1
xpath ×1
xslt ×1