We are using Team Build to handle our deployments to our development server, and we have a need to remove comments from our web config when it's transformed. Does anyone know how to remove the <!-- -->
comment lines from the web config file using a transformation?
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.
Select the lines you want to be commented in your ASPX, HTML, web config file etc and click on the Comment/ Uncomment icon in Toolbar. Alternatively you can use Keyboard shortcut Ctrl+K Ctrl+C to comment and use Ctrl+K Ctrl+U to uncomment.
Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix. There are xdt:Transform and xdt:Locator attributes that we use in the Web. Config file. So, xdt:Locator locates element(s) and xdt:transform specifies the action over it.
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.
I've found an answer. It seems this is a known bug in the XDT transformation engine in Visual Studio/Team Build. This bug was reported in March, so no idea when this will be fixed.
Here's the link
Edit: This link actually isn't related to the original question. We eventually figured it wasn't possible with the built-in web config transformations. So we ended up writing a console application to strip comments, and properly format the transformed file.
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