我对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>
答案 0 :(得分:1)
重建目标是为每个项目定义的预定义的msbuild目标,在csharp的情况下,每个csproj中都有一个指向msbuild库的链接 - 使用行<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />.
嵌入在文件中这是目标重建从<Target Name="Rebuild">