Perform XSLT Transform as Build-Step

自作多情 提交于 2019-12-21 03:36:33

问题


During a Visual Studio build, I need to have an XML file generated from another XML file. It is obvious to me an XSLT template and transform is exactly what I need.

The way I prefer to accomplish this is to use the "Custom Tool" property found on project files. Is there already a built-in tool I can use for this purpose? My next option might be to use a pre-build step of the csproj. Again, is there a (Visual Studio or MSBUILD) pre-existing or pre-installed tool that I can invoke from a pre-build step to do this?

Finally, if need be, I could have modify the .csproj file itself to add a MSbuild Task which performs the transform (I think MSBuild comes with such a Task - if not I know they are available for download).

Overall, I'd just like to know the easiest way to get this done, and how to do it. I already know how to write XSL templates. :)


回答1:


If you're using VS2010 you can use the built-in XslTransformation task of MSBuild 4 in a post build step.

<Target Name="AfterBuild">
  <XslTransformation
    XslInputPath="transform.xslt"
    XmlInputPaths="in.xml"
    OutputPaths="out.xml" />
</Target>



回答2:


I'd personally go with installing the MSBuild Community Tasks and invoking msbuild.exe from the PostBuild Event in the project settings.

A shudder just went down my spine at the thought of XSLT files too! :P



来源:https://stackoverflow.com/questions/6962721/perform-xslt-transform-as-build-step

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!