I use MSBuild community tasks to run Xsd.exe as part of my build in Visual Studio, for example:
<Import Project="$(SolutionDir)Common.targets" /> <PropertyGroup> <MSBuildCommunityTasksPath>$(SolutionDir)TeamBuildTypes</MSBuildCommunityTasksPath> </PropertyGroup> <Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets" /> <UsingTask TaskName="XSD" AssemblyFile="$(VCTargetsPath)$(CPPTasks)" /> <Target Name="BeforeBuild"> <XSD Sources="MySchema.xsd" GenerateFromSchema="classes" Language="CS" /> </Target>
Common.targets matches here .
However, during build I get the following error:
Failed to complete the "XSD" task.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal error MSBuild: xsd.exe unexpectedly not rooted path
The MSDN forum is here which should be called vsvars32.bat in advance. This is a commented line in the code above. This did not work, so I found a solution here that I was hoping would make it work, namely: DEVENV with the /useenv .
Then I found another solution here that should add <xs:include schemaLocation="MSBuild\MSBuild.Community.Tasks.xsd"/> to Microsoft.Build.xsd . Does not work.
So now I have no ideas. How to get an XSD task for MSBuild community tasks without requiring developers to update the path variable, either using the /useenv solution or some other solution? I know that I can install xsd.exe in a Visual Studio solution, but this seems like a cheap workaround for me.
source share