使用SlowCheetah扩展插件解决测试环境和生产环境xml配置文件内容切换
2017-07-19 18:28
639 查看
https://marketplace.visualstudio.com/items?itemName=WillBuikMSFT.SlowCheetah-XMLTransforms
This package allows you to automatically transform your app.config (or any file) when you press F5 in Visual Studio. You can have different transformations based on the build configuration. This will enable you to easily have different app settings, connection
strings, etc for Debug versus Release. If you want to transform other files you can do that too. Here are some other reasons why you might want to install this package.
Have you ever:
Wanted to have different appSettings for debug and release when building your
app?
Wanted to use different connection strings based on your build configuration
when building your app?
Wanted to transform any XML file with a clean and simple syntax?
Wanted to tweak WCF service configuration in a straight foward way?
Wanted to preview your XML transform without building/publishing your app?
Wanted to transform files in addition to web.config on publish for Web projects?
If you answered Yes to any of these then you should download this package.
Getting started is really simple, just install this package. Then in the solution explorer you can easily add your config transform by right-clicking and selecting Add Transform.
After you add the transform you will notice a transform for each build configuration.
You can place your customizations inside of the transform files, for example if you want to tweak app settings and connection strings you might use the syntax shown below.
When you build your applicatoin the files are transformed and dropped into the output directory. If you are transforming the app.config then when the file is transformed it will be renamed in the output directory as usual to ensure that your application picks
it up at runtime.
For web projects the files are transformed when you publish or package your application.
You can also quickly preview your transform using the Preview Transform context menu on the transform file.
In version 1.3 we now have support for Setup projects. If your setup project has the Project Outputs of a referenced project which is using SlowCheetah then the transformed app.config will be the configuraiton file used which is laid on disk in the installer.
In version 1.3 we have added support for ClickOnce. If you publish a project with ClickOnce which uses SlowCheetah then the transformed files (instead of the source files) will be published.
We now (as of version 1.3) have support for F# projects. When you add a transform into an F# project they will not show up as child items, but the transformations will run correctly.
If you need some help please do not post in the QA here, instead use these methods.
For new features create an entry on slowcheetah.uservoice.com
For bug reports create an issue on the issues page for the project
What
This package allows you to automatically transform your app.config (or any file) when you press F5 in Visual Studio. You can have different transformations based on the build configuration. This will enable you to easily have different app settings, connectionstrings, etc for Debug versus Release. If you want to transform other files you can do that too. Here are some other reasons why you might want to install this package.
Have you ever:
Wanted to have different appSettings for debug and release when building your
app?
Wanted to use different connection strings based on your build configuration
when building your app?
Wanted to transform any XML file with a clean and simple syntax?
Wanted to tweak WCF service configuration in a straight foward way?
Wanted to preview your XML transform without building/publishing your app?
Wanted to transform files in addition to web.config on publish for Web projects?
If you answered Yes to any of these then you should download this package.
How
Getting started is really simple, just install this package. Then in the solution explorer you can easily add your config transform by right-clicking and selecting Add Transform.After you add the transform you will notice a transform for each build configuration.
You can place your customizations inside of the transform files, for example if you want to tweak app settings and connection strings you might use the syntax shown below.
<?xml version="1.0" encoding="utf-8" ?> <!-- For more information on using transformations see the web.comfig examples at http://go.microsoft.com/fwlink/?LinkId=214134. --> <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <appSettings> <add key="appName" value="WPF Demo-Release" xdt:Transform="Replace" xdt:Locator="Match(key)"/> <add key="url" value="http://contoso.com/" xdt:Transform="Replace" xdt:Locator="Match(key)"/> <add key="email" value="release@contoso.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/> </appSettings> <connectionStrings> <add name="RecordsDb" connectionString="db.contoso.com;Initial Catalog=RecordsDb;Integrated Security=true" xdt:Transform="Replace" xdt:Locator="Match(name)"/> <add name="InventoryDb" connectionString="db.constos.com;Initial Catalog=InventoryDb;Integrated Security=true" xdt:Transform="Insert" xdt:Locator="Match(name)" /> </connectionStrings> </configuration>
When you build your applicatoin the files are transformed and dropped into the output directory. If you are transforming the app.config then when the file is transformed it will be renamed in the output directory as usual to ensure that your application picks
it up at runtime.
For web projects the files are transformed when you publish or package your application.
You can also quickly preview your transform using the Preview Transform context menu on the transform file.
Setup Projects
In version 1.3 we now have support for Setup projects. If your setup project has the Project Outputs of a referenced project which is using SlowCheetah then the transformed app.config will be the configuraiton file used which is laid on disk in the installer.
ClickOnce
In version 1.3 we have added support for ClickOnce. If you publish a project with ClickOnce which uses SlowCheetah then the transformed files (instead of the source files) will be published.
F# Projects
We now (as of version 1.3) have support for F# projects. When you add a transform into an F# project they will not show up as child items, but the transformations will run correctly.
Getting Help
If you need some help please do not post in the QA here, instead use these methods.For new features create an entry on slowcheetah.uservoice.com
For bug reports create an issue on the issues page for the project
相关文章推荐
- 使用Maven自动打包配置文件生成开发环境,测试环境,生产环境
- maven: 开发、测试和生产环境使用不同的配置文件例子
- Java日志框架-logback配置文件多环境日志配置(开发、测试、生产)(原始解决方法)
- bash变量-数值运算与运算符/变量测试与内容替换/环境变量配置文件
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- 使用Hibernate时,hibernate.cfg.xml的配置文件内容
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
- 《jbpm5-eclipse插件ant安装失败时》---将build.xml文件改为以下文件内容(经测试,该文章用firefox打开最佳)
- 解决使用Oracle库利用MyBatis配置文件逆向生成的实体类时mapping.xml里有重复的节点问题
- 【maven】之配置开发,测试,正式环境pom.xml文件
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- springboot 多环境(开发、测试、生产)部署配置文件方案
- 004,配置文件之使用rabbitmq-env.conf,rabbitmq.config在生产环境的应用和和一些注意的问题
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- mybatis进行测试时找不到配置文件:java.io.IOException: Could not find resource config/SqlMapConfig.xml 的解决
- python程序如何在生产和测试环境自动调用对应的配置文件
- 通过maven管理项目的生产、开发和测试环境的配置文件
- 通过 spring 容器内建的 profile 功能实现开发环境、测试环境、生产环境配置自动切换
- 使用Maven Profile按需加载开发、测试和产品环境的配置文件
- WebPack安装-使用-Loader-配置-插件-环境-排错详解(下扩展)