我对 MSBuild 的 Targets 属性和一般 Target 标记感到困惑。
下面的代码是否编译成 msbuild myapp.sln /t:Rebuild
.NET 中的“重建”预定义目标。
<Target Name="Build" DependsOnTargets="Clean">
<MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild"/>
</Target>
编辑:
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="Full" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>...</PropertyGroup>
<ItemGroup>...</ItemGroup>
<Target Name="Clean">
<Message Text="Cleaning..."/>
<RemoveDir Directories="$(BuildWebOutputDir);$(BuildRoot)" />
</Target>
<Target Name="Build">
<Message Text="Building solution..."/>
<MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild">
</MSBuild>
</Target>
<Target Name="Copy">
<Message Text="Copying..."/>
<Exec Command="xcopy.exe $(BuildWebOutputDir) $(DistDir) /e /f /y /i" />
</Target>
<Target Name="Full" DependsOnTargets="Clean;Build;Copy">
</Target>
<Target>
</Project>