Skip to content

Build reports success when an AfterTargets errors #3345

@cdmihai

Description

@cdmihai

Steps to reproduce

1.proj

<Project DefaultTargets="Build">
    <Target Name="Build">
        <MSBuild Projects="2.proj" Targets="Build"/>
    </Target>
</Project>

2.proj

<Project DefaultTargets="Build">
    <Target Name="Build" />

    <Target Name="IndirectBuild" AfterTargets="Build">
        <Error Text="Induce failure" />
    </Target>
</Project>

build with

set MSBUILDNOINPROCNODE=1

msbuild.exe 1.proj /clp:ShowCommandLine /m:1 /verbosity:n /nr:false /bl /fl /flp:v=diagnostic

Expected behavior

Build fails because of the <Error> task

Actual behavior

Build succeeds:

Build started 5/24/2018 5:35:56 PM.
Project "e:\delete\repro\1.proj" on node 2 (default targets).
Project "e:\delete\repro\1.proj" (1) is building "e:\delete\repro\2.proj" (2) on node 2 (Build target(s)).
e:\delete\repro\2.proj(5,9): error : Induce failure
Done Building Project "e:\delete\repro\2.proj" (Build target(s)) -- FAILED.

Done Building Project "e:\delete\repro\1.proj" (default targets).

Deferred Messages

  Detailed Build Summary
  ======================


  ============================== Build Hierarchy (IDs represent configurations) =====================================================
  Id                  : Exclusive Time   Total Time   Path (Targets)
  -----------------------------------------------------------------------------------------------------------------------------------
  0                   : 0.101s           0.120s       e:\delete\repro\1.proj ()
  . 1                 : 0.018s           0.018s       e:\delete\repro\2.proj (Build)

  ============================== Node Utilization (IDs represent configurations) ====================================================
  Timestamp:            2        Duration   Cumulative
  -----------------------------------------------------------------------------------------------------------------------------------
  636628053566714538:   0        0.096s     0.096s #
  636628053567674882:   1        0.018s     0.114s
  636628053567855025:   0        0.007s     0.121s
  -----------------------------------------------------------------------------------------------------------------------------------
  Utilization:          100.0    Average Utilization: 100.0

Build succeeded.

"e:\delete\repro\1.proj" (default target) (1) ->
"e:\delete\repro\2.proj" (Build target) (2) ->
(IndirectBuild target) ->
  e:\delete\repro\2.proj(5,9): error : Induce failure

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.22

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions