Visual Studio在构建时创建XML文档。我有一个想应用的xml样式表(xslt)。我想将此行添加到生成的文件中:
<?xml-stylesheet type="text/xsl" href="Documentation.xsl"?>
最好在构建时添加xslt声明。有没有办法做到这一点?
我通过创建一个后构建批处理脚本解决了这个问题。它使用fart.exe将xsl样式表声明添加到我的XML中。我将其添加为Visual Studio项目中的构建后步骤。
::Postbuild script.
::Adds xsl stylesheet to XML documentation
::%1 is the project directory string
::Only add a stylesheet if it's not already there
findstr /m "xml-stylesheet" %1Documentation\MCM.XML
if %errorlevel%==1 (
::Use "Find and Replace Text" (fart.exe) to add xml-stylesheet declaration
"%1Documentation/fart.exe" -C -q "%1Documentation\MCM.XML" "<\?xml version=\"1.0\"\?>" "<\?xml version=\"1.0\"\?><\?xml-stylesheet type=\"text/xsl\" href=\"Documentation.xsl\"\?>"
if %errorlevel%==9009 (
echo .
) else (
if ERRORLEVEL 1 CMD /C EXIT 0
)
) else (
cmd /C EXIT 0
)
exit %errorlevel%
感谢@Yaman为我指出正确的方向。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句