title: Before and AfterBuild Target in Visual Studio not firing
body: <p>I am doing the following:</p>
  
  <ul>
  <li>I have created a default class file project</li>
  <li>Edited the csproj file to include Pre and Post BuildEvents</li>
  <li>Uncomment the default commented out BeforeBuild and AfterBuild targets</li>
  </ul>
  
  <p>The BeforeBuild and AfterBuild targets are not called form within Visual Studio but are from msbuild command line, why is that?</p>
  
  <p>I would rather use msbuild targets rather than the PostBuildEvent as if gives me more power and flexibility, assuming it works.</p>
  
  <p>Cheers,</p>
  
  <p>adam</p>
  
  <p><em>I shortened some of the paths in the output, so if they are inconsistent that is why</em></p>
  
  <hr>
  
  <p>ClassLibrary1.csproj changes</p>
  
  <pre><code>&lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt;
  &lt;Target Name="BeforeBuild"&gt;
    &lt;Message Text="### BeforeBuild ###" /&gt;
  &lt;/Target&gt;
  &lt;Target Name="AfterBuild"&gt;
    &lt;Message Text="### AfterBuild ###" /&gt;
  &lt;/Target&gt;
  &lt;PropertyGroup&gt;
    &lt;PreBuildEvent&gt;echo PRE_BUILD&lt;/PreBuildEvent&gt;
  &lt;/PropertyGroup&gt;
  &lt;PropertyGroup&gt;
   &lt;PostBuildEvent&gt;echo POST_BUILD&lt;/PostBuildEvent&gt;
  &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>my build output from VS 2010 is</p>
  
  <pre><code>------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
  PRE_BUILD
  ClassLibrary1 -&gt; c:\ClassLibrary1\bin\Debug\ClassLibrary1.dll
  POST_BUILD
  ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  </code></pre>
  
  <p>and from the command line</p>
  
  <pre><code>#&gt;msbuild ClassLibrary1.sln
  Microsoft (R) Build Engine Version 4.0.30319.1
  [Microsoft .NET Framework, Version 4.0.30319.239]
  Copyright (C) Microsoft Corporation 2007. All rights reserved.
  
  Build started 09/05/2012 13:27:42.
  Project "c:.sln" on node 1 (default targets).
  ValidateSolutionConfiguration:
    Building solution configuration "Debug|Any CPU".
  Project "c:.sln" (1) is building "c:\ClassLibrary1.csproj" (2) on node 1 (default targets).
      BeforeBuild:
        ### BeforeBuild ###
  PreBuildEvent:
    echo PRE_BUILD
    PRE_BUILD
  GenerateTargetFrameworkMonikerAttribute:
  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
  CoreCompile:
  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
  CopyFilesToOutputDirectory:
    ClassLibrary1 -&gt; c:\bin\Debug\ClassLibrary1.dll
  PostBuildEvent:
    echo POST_BUILD
    POST_BUILD
  AfterBuild:
    ### AfterBuild ###
  Done Building Project "c:\ClassLibrary1.csproj" (default targets).
  
  Done Building Project "c:.sln" (default targets).
  
  Build succeeded.
      0 Warning(s)
      0 Error(s)
  
  Time Elapsed 00:00:00.18
  </code></pre>