Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove XML comments using Visual Studio 2010 Web Config Transformation

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?

like image 240
Dylan Vester Avatar asked Jun 02 '10 14:06

Dylan Vester


People also ask

What is Xdt transform in web config?

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.

How do you comment out a line in web config?

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.

How does web config transform work?

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.

What is Slowcheetah?

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.


1 Answers

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.

like image 200
Dylan Vester Avatar answered Nov 15 '22 04:11

Dylan Vester