I have the following inline task defined in a .csproj file that should run BeforeBuild.
<UsingTask TaskName="VersioningTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<FileName ParameterType="System.String" Required="true" />
<XmlFileName ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml.dll" />
<Reference Include="System.Xml.Linq.dll"/>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text" />
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="System.Xml.Linq" />
<Code Type="Fragment" Language="cs"><![CDATA[
var xDoc = XDocument.Load(XmlFileName);
//...
When building the project from VS2012 I get the following error:
Could not find reference "System.Xml.dll". If this reference is required by your code, you may get compilation errors.
Could not find reference "System.Xml.Linq.dll". If this reference is required by your code, you may get compilation errors.
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.
Any ideas whats wrong here are highly appreciated.
I had the same exact problem when referencing System.Xml.Linq. Switching to a compiled task does solve your solution, but to implement the original code as an Inline Task, simply drop the file extension from the references then your inline task so that you reference the root namespace rather than the file name.
Change this:
<Reference Include="System.Xml.dll" />
<Reference Include="System.Xml.Linq.dll"/>
To read:
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With