即使条件为假,MSBuild 也会构建目标
MSBuild builds target even though condition is false
我有一个构建目标的 MSBuild 项目文件,即使它的条件为 false
<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 个是最新的。
对不起。如果我将目标行更改为
它会起作用
<Target Name="MakeBuildDir" Condition="!Exists('$(BuildDir)')">
(虽然它仍然显示成功,但不是最新的....)
我有一个构建目标的 MSBuild 项目文件,即使它的条件为 false
<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 个是最新的。
对不起。如果我将目标行更改为
它会起作用<Target Name="MakeBuildDir" Condition="!Exists('$(BuildDir)')">
(虽然它仍然显示成功,但不是最新的....)