即使条件为假,MSBuild也会构建目标

时间:2016-09-16 20:45:17

标签: visual-studio visual-studio-2010 msbuild

我有一个MSBuild项目文件,即使其条件为假

也会构建目标
<PropertyGroup>
  <BuildDir>$(ProjectDir)build\</BuildDir>
</PropertyGroup>
<Target Name="MakeBuildDir" Condition="!Exists('($BuildDir)')">
  <MakeDir Directories="$(BuildDir)" />
</Target>

BuildDir确实存在,无论如何它都会运行此任务。

从日志文件中:

15:32:17.162     1>Target "MakeBuildDir: (TargetId:3)" in project "foo.vcxproj" (target "bar" depends on it):
                   Using "MakeDir" task from assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
                   Task "MakeDir" (TaskId:4)
                   Done executing task "MakeDir". (TaskId:4)
15:32:17.162     1>Done building target "MakeBuildDir" in project "KB.vcxproj".: (TargetId:3)
15:32:17.162     1>Target "bar: (TargetId:4)" in project "foo.vcxproj" (target "Build" depends on it):
                   Skipping target "bar" because all output files are up-to-date with respect to the input files.

这对我来说不是一个至关重要的问题,但如果我立即对我的解决方案进行两次构建,我希望第二个向我展示我的所有11个项目都是最新的。现在需要几秒钟然后说2个成功,9个是最新的。

1 个答案:

答案 0 :(得分:1)

对不起。如果我将目标线更改为

,它会起作用
<Target Name="MakeBuildDir" Condition="!Exists('$(BuildDir)')">

(虽然它仍显示为成功,但不是最新的......)