How to specify a "Custom Tool" to convert the file to VS2010?

The Properties window in VS2010 for most file types (for example, .cs, .xml, .xslt) allows you to specify a custom tool for converting files. For reference, here is the tool tip that you get when you select the Custom Tool field.

Specifies a tool that converts the file at design time and puts the output of this conversion into another file. For example, a dataset (.xsd) comes with a standard custom tool.

I am looking for information on how to set and use this property.

Here is the problem I'm trying to solve. I also convert the XML file using XSLT. I use extension objects during conversion, as described here .

In doing so, I visualized Visual Studio as a tool for editing and debugging my XSLT. I hope that I can write a simple conversion mechanism that allows us to use Visual Studio in the same way as for XSLT documents that do not use extension objects. I think (hopefully) that the Custom Tool property is the key to doing this work.

TIA

+7
source share
3 answers

Debugging XSLT transformations with extension functions with the option of having breakpoints in both XSLT code and extension function code is supported with VS2005 .

Just use this XslCompiledTransform constructor overload .

Parameters enableDebug Type: System.Boolean true to generate debugging information; otherwise false. Setting this value to true allows you to debug the stylesheet using the Microsoft Visual Studio Debugger.

Notes

To enter the code and debug the style sheet, the following conditions must be met:

The enableDebug parameter is true.

  • The stylesheet is passed to Load either as a URI or an implementation of the XmlReader class that implements the IXmlLineInfo interface. The IXmlLineInfo interface IXmlLineInfo implemented in all text parsing of XmlReader objects.

    In other words, if a stylesheet is loaded using an IXPathNavigable object, for example, an XmlDocument or XPathDocument , or an XmlReader implementation that does not implement the IXmlLineInfo interface, you cannot debug the stylesheet.

  • XmlResolver used to load the stylesheet - this is the file- XmlResolver , for example, XmlUrlResolver (this is the default XmlResolver used by XslCompiledTransform ).

  • The style sheet is located on the local computer or intranet.

Here is an example of a little code :

 // Enable XSLT debugging. XslCompiledTransform xslt = new XslCompiledTransform(true); // Load the style sheet. xslt.Load("output.xsl"); // Create the writer. XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent=true; XmlWriter writer = XmlWriter.Create("output.xml", settings); // Execute the transformation. xslt.Transform("books.xml", writer); writer.Close(); 
+2
source

A workaround for debugging XSLT files using extension objects is to create a test .exe file project (for example, a console application project) and call XSLT (with all extension objects correctly specified) from this project.

You can set breakpoints, then "Start Debugging" the .exe project to enter the XSLT file.

+1
source

Until 2010, the Custom Tool property indicated the name of the class that was registered with VS as a processing tool that takes the value of a project element and creates more files. To do this, you had to write a tool class, compile it into an assembly, and register this assembly using Visual Studio. An example of this process can be found here , but note that this is not specifically for VS 2010 and therefore may break - based on custom tools on the COM object model for VS, obviously .

I'm not sure how well this feature is supported in VS 2010. I have not seen any (obvious) documentation on writing these tools in the VS 2010 SDK and this Visual Studio blog post discusses this feature (in the "Custom build tools" section) or similar one, but I never saw any user interface described in my copy of VS 2010.

In any case, if you are just trying to run some things through the command line, you might be better off simply editing your .csproj's MSBuild to use the <Exec> task - if you want to create a custom tool, my first link, hopefully at least you will start.

+1
source

All Articles