1

In my project, I am using several schematron(XML) files and build the project using MSBuild script.

Is there any way in MSBuild or in Powershell Commands to validate those XML files against XSD file like <validatexml> tag in NAnt??

If yes, then Please provide any example that shows how can we do it?

Charu
  • 13
  • 5
  • http://stackoverflow.com/questions/822907/how-do-i-use-powershell-to-validate-xml-files-against-an-xsd – Naigel Jul 30 '14 at 08:54
  • Thanks @Naigel for Powershell Commands.Is there any way in MSBuild for that or not? – Charu Jul 31 '14 at 18:04

1 Answers1

2

If you use the PowerShell Community Extensions there is a Test-Xml cmdlet that will validate XML e.g.

<Exec Command='PowerShell.exe -Command "& {Test-Xml -Path $(XmlPath) -Validate}"/>

Avoid using the -File parameter on PowerShell.exe. Certain versions of PowerShell don't return the correct exit code when this parameter is used.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369