title: Use custom MSBuild tasks from the same solution?
body: <p>I'm a new to MSBuild and wanted to play around with it a bit, but I just cannot figure out why this isn't working.</p>
  
  <p>So my solution has two projects: "Model" and "BuildTasks".  BuildTasks just has a single class:</p>
  
  <pre><code>using Microsoft.Build.Utilities;
  
  namespace BuildTasks
  {
      public class Test : Task
      {
          public override bool Execute()
          {
              Log.LogMessage( "FASDfasdf" );
              return true;
          }
      }
  }
  </code></pre>
  
  <p>And then in the Model.csproj I've added this:</p>
  
  <pre><code>  &lt;UsingTask TaskName="BuildTasks.Test" AssemblyFile="$(SolutionDir)src\BuildTasks\bin\BuildTasks.dll" /&gt;
    &lt;Target Name="AfterBuild"&gt;
      &lt;Test /&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>I've set up the build order so "BuildTasks" gets built before "Model".  But when I try to build Model I get this error:</p>
  
  <blockquote>
    <p>The "BuildTasks.Test" task could not
    be loaded from the assembly
    C:\WIP\TestSolution\src\BuildTasks\bin\BuildTasks.dll.
    Could not load file or assembly
    'file:///C:\WIP\TestSolution\src\BuildTasks\bin\BuildTasks.dll'
    or one of its dependencies. The system
    cannot find the file specified.
    Confirm that the &lt;UsingTask&gt;
    declaration is correct, and that the
    assembly and all its dependencies are
    available.</p>
  </blockquote>
  
  <p>This file definitely exists, so why can't MSBuild find it?</p>
  
  <p>I've even tried hard-coding "C:\WIP\TestSolution" in place of "$(SolutionDir)" and get the same error.  However, if I copy that .dll to my desktop and hard-code the path to my desktop, it <em>DOES</em> work, which I can't figure out why.</p>
  
  <p><strong>EDIT</strong>: I don't have the path wrong.  I modified the Debug/Release builds for BuildTasks to output the .dll to just the bin folder since I didn't want Debug/Release to have different paths.</p>