title: MSBuild referencing DLL's in Task
body: <p>I have the following inline task defined in a .csproj file that should run BeforeBuild.</p>
  <pre><code>&lt;UsingTask TaskName=&quot;VersioningTask&quot; TaskFactory=&quot;CodeTaskFactory&quot; AssemblyFile=&quot;$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll&quot;&gt;
  &lt;ParameterGroup&gt;
      &lt;FileName ParameterType=&quot;System.String&quot; Required=&quot;true&quot; /&gt;
      &lt;XmlFileName ParameterType=&quot;System.String&quot; Required=&quot;true&quot; /&gt;
  &lt;/ParameterGroup&gt;
  &lt;Task&gt;
      &lt;Reference Include=&quot;System.Xml.dll&quot; /&gt;
      &lt;Reference Include=&quot;System.Xml.Linq.dll&quot;/&gt;
      &lt;Using Namespace=&quot;System&quot; /&gt;
      &lt;Using Namespace=&quot;System.IO&quot; /&gt;
      &lt;Using Namespace=&quot;System.Linq&quot; /&gt;
      &lt;Using Namespace=&quot;System.Text&quot; /&gt;
      &lt;Using Namespace=&quot;System.Text.RegularExpressions&quot; /&gt;
      &lt;Using Namespace=&quot;System.Xml.Linq&quot; /&gt;
      &lt;Code Type=&quot;Fragment&quot; Language=&quot;cs&quot;&gt;&lt;![CDATA[
          var xDoc = XDocument.Load(XmlFileName);
          //...
  </code></pre>
  <p>When building the project from VS2012 I get the following error:</p>
  <blockquote>
  <p>Could not find reference &quot;System.Xml.dll&quot;. If this reference is required by your code, you may get compilation errors.</p>
  <p>Could not find reference &quot;System.Xml.Linq.dll&quot;. If this reference is required by your code, you may get compilation errors.</p>
  </blockquote>
  <p>If I remove the XML stuff and the two references, the build succeeds.
  I have tried to use full paths to the DLL's (%windir%/assembly) without any success.</p>
  <p>Any ideas whats wrong here are highly appreciated.</p>