title: Task could not be loaded from assembly
body: <p>I have an error in one of my projects at work. The error says:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error     The "StyleCopTask" task could not be loaded from the assembly
    C:\Projects\Project
    Name\Source\\MSBuild\StyleCop\v4.7\StyleCop.dll. Could not load
    file or assembly 'Microsoft.Build.Utilities.v3.5, Version=3.5.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
    dependencies. The system cannot find the file specified. Confirm that
    the  declaration is correct, that the assembly and all its
    dependencies are available, and that the task contains a public class
    that implements
    Microsoft.Build.Framework.ITask.  DskDirectMarketing.Common</p>
  </blockquote>
  
  <p>Here I can clearly see that there is problem in the relative path which VS is looking for StyleCop. Here is how it looks like:</p>
  
  <pre><code>&lt;Import Project="$(SolutionDir)\MSBuild\StyleCop\v4.7\StyleCop.targets" /&gt;
  </code></pre>
  
  <p>and my SolutionDir declaration looks like this:</p>
  
  <pre><code>&lt;SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'"&gt;..\&lt;/SolutionDir&gt;
  </code></pre>
  
  <p>After some digging I noticed that in the error which prompts me there are 2 slashes:</p>
  
  <blockquote>
    <p>C:\Projects\Project Name\Source\MSBuild\StyleCop\v4.7\StyleCop.dll</p>
  </blockquote>
  
  <p>First thing I tried was to remove the dash from</p>
  
  <pre><code>&lt;Import Project="$(SolutionDir)MSBuild\StyleCop\v4.7\StyleCop.targets" /&gt;
  </code></pre>
  
  <p>Id didn't worked.
  After that I tried to put the absolute path but I had 2 slashes again.</p>
  
  <p>How can I resolve this issue? Any help would be appreciated.</p>