您的位置:首页 > 其它

使用SlowCheetah扩展插件解决测试环境和生产环境xml配置文件内容切换

2017-07-19 18:28 639 查看
https://marketplace.visualstudio.com/items?itemName=WillBuikMSFT.SlowCheetah-XMLTransforms


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, 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.


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

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐