Domanda

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.

È stato utile?

Soluzione

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"/>

Altri suggerimenti

Solved it by using regular tasks instead of using inline tasks.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top