我有一个项目,它从XSD定义生成一个类,然后构建它。我的问题是,即使我指定了我的Xsd目标的输入和输出,它仍然会在每次构建Visual Studio解决方案时执行。这可能是什么问题?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" InitialTargets="Xsd" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- snip -->
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="request.cs">
<DependentUpon>request.xsd</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
<Xsd Include="request.xsd" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="Xsd" Inputs="@(Xsd)" Outputs="request.cs">
<Exec Command='"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\xsd.exe" "@(Xsd)" /c /o:..\.. /n:Order.Messaging' />
</Target>
</Project>
答案 0 :(得分:1)
初始目标通常用于错误检查。
并将依赖项添加到BeforeBuild Target:
<Target Name="BeforeBuild" DependsOnTargets="Xsd" />