4

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.

4

2 回答 2

11

我在引用 System.Xml.Linq 时遇到了同样的问题。切换到已编译任务确实可以解决您的解决方案,但是要将原始代码实现为内联任务,只需从引用中删除文件扩展名,然后删除内联任务,以便引用根命名空间而不是文件名。

改变这个:

<Reference Include="System.Xml.dll" />
<Reference Include="System.Xml.Linq.dll"/>

读书:

<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"/>
于 2013-07-17T01:20:23.290 回答
-1

通过使用常规任务而不是使用内联任务来解决它。

于 2013-04-26T20:12:52.853 回答