title: MS-Build BeforeBuild not firing
body: <p>I'm customising a <code>.csproj</code> project to run some custom tasks before the main build. However, I can't get the tasks to execute at all. </p>
  
  <p>I uncommented the <code>&lt;Target Name="BeforeBuild" /&gt;</code> element in the <code>.csproj</code> file and added a simple Message task, but when I build, the message doesn't appear in my output, so it seems the task isn't running. So this fragment does not output the message;</p>
  
  <p><strong>Listing 1: No Message Appears</strong></p>
  
  <pre><code>&lt;Target Name="BeforeBuild"&gt;
      &lt;Message Text="About to build ORM layer" Importance="normal" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>However, if I screw with some of the attributes, I can get the <code>.csproj</code> to fail to execute at all;</p>
  
  <p><strong>Listing 2: An MSBuild configuration error</strong></p>
  
  <pre><code>&lt;Target Name="BeforeBuild"&gt;
      &lt;Message Text="About to build ORM layer" XXImportance="normal" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>Note the <code>XXImportance</code> attribute. The build error I get is</p>
  
  <pre><code>My.csproj(83,46): error MSB4064: The "XXImportance" parameter is not supported by the "Message" task. Verify the parameter exists on the task, and it is a settable public instance property.
  </code></pre>
  
  <p>This suggests that the XML is being parsed, that the <code>Message</code> class has been found, and that the class is being reflected over for the available properties. </p>
  
  <p>Why would the task not execute?</p>
  
  <p>I'm using the 3.5 framework.</p>
  
  <p><strong>UPDATE 1:</strong> On @Martin's advice, I tried to run MSBuild on the console, and got this error;</p>
  
  <pre><code>c:\path\to\my.csproj(74,11): error MSB4019: The imported
  project "C:\Microsoft.CSharp.targets" was not found. Confirm
  that the path in the &lt;Import&gt; declaration is correct, and that
  the file exists on disk.
  </code></pre>
  
  <p>Line 74 reads;</p>
  
  <pre><code>&lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&gt;
  </code></pre>
  
  <p><strong>UPDATE 2:</strong> I'm compiling in VS2008, which uses the C#3 compiler, but the project I'm compiling is a framework 2.0 project. When run from the command line (see UPDATE 1) the build seems to fail because there is a confusion as to where the <code>Microsoft.CSharp.targets</code> file is specified.</p>