I have following config for my mail:
<system.net>
<mailSettings>
<smtp from="[email protected]" deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:/test"/>
<network host="localhost" userName="" password=""/>
</smtp>
</mailSettings>
</system.net>
This is my .Release version:
<system.net>
<mailSettings>
<smtp from="[email protected]" xdt:Transform="RemoveAttributes(deliveryMethod)">
<network xdt:Transform="Replace" host="192.168.1.9" userName="" password="" />
</smtp>
</mailSettings>
</system.net>
How do I remove
<specifiedPickupDirectory pickupDirectoryLocation="C:/test"/>
so it doesn't show in my .Release at all?
Also, I would like to remove other namespaces like System.Diagnostics
completely. What is the syntax for doing so?
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).
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.
A transform file is an XML file that specifies how the Web. config file should be changed when it is deployed. Transformation actions are specified by using XML attributes that are defined in the XML-Document-Transform namespace, which is mapped to the xdt prefix.
For specifiedPickupDirectory
element this should work:
<specifiedPickupDirectory xdt:Transform="RemoveAll" />
.
For System.Diagnostics:
<system.diagnostics xdt:Transform="RemoveAll"></system.diagnostics>
<system.net>
<mailSettings>
<smtp from="[email protected]" xdt:Transform="Replace">
<network xdt:Transform="Replace" host="192.168.1.9" userName="" password="" />
</smtp>
</mailSettings>
</system.net>
This will replace that entire tag with yours.. hope this is what you are looking for..
the good thing about this is that you dnt end up polluting your transform config with unnecessary remove commands like some of the answers stated here..
consider the case where you have more than one child tags..
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