I would like to apply a transformation if and only if a matched element does not exist in the target. Trying various xpath expressions using http://webconfigtransformationtester.apphb.com/ but no luck so far.
E.g. if the target web.config looks like this:
<configuration> <system.web> <compilation debug="true" /> </system.web> </configuration>
then the output should look like this:
<configuration> <connectionStrings> <add name="MyCs" provider="System.Data.SqlClient" connectionString="" /> <add name="SomeOtherCs" provider="System.Data.SqlClient" connectionString="" /> </connectionStrings> <system.web> <compilation debug="true" /> </system.web> </configuration>
But if the target looks like this:
<configuration> <connectionStrings> <add name="MyCs" provider="System.Data.IChangedIt" connectionString="my connection string here" /> </connectionStrings> <system.web> <compilation debug="true" /> </system.web> </configuration>
then the result of the transformation should look like this:
<configuration> <connectionStrings> <add name="MyCs" provider="System.Data.IChangedIt" connectionString="my connection string here" /> <add name="SomeOtherCs" provider="System.Data.SqlClient" connectionString="" /> </connectionStrings> <system.web> <compilation debug="true" /> </system.web> </configuration>
In other words, I just want to add the named connection string to configuration but let the administrator fill it in with his own values. I thought it would as simple as xdt:Transform="Insert" xdt:Locator="XPath(count(/configuration/connectionStrings)=0)"
(to add a cs config section if none existed) but apparently not.
The xdt:Transform="RemoveAttributes(debug)" attribute specifies that you want the debug attribute to be removed from the system. web/compilation element in the deployed Web. config file. This will be done every time you deploy a Release build.
If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).
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 are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project.
Use xdt:Transform="InsertIfMissing"
with the XmlTransform
task in VS2012. It doesn't look like Microsoft has updated their documentation to reflect this yet.
In my case xdt:Transform="InsertIfMissing"
did not work without xdt:Locator="Match(name)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With