在visual studio online tfs build上缺少Microsoft.Build.Tasks.v4.0.dll

Pou*_*sen 9 tfs azure-devops

我正在尝试使用visual studio在线构建我的项目.

我收到以下错误.

C:\a\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

这来自我的解决方案中的nuget.targets文件.

  <UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
        <ParameterGroup>
            <EnvKey ParameterType="System.String" Required="true" />
            <EnvValue ParameterType="System.String" Required="true" />
        </ParameterGroup>
        <Task>
            <Using Namespace="System" />
            <Code Type="Fragment" Language="cs">
                <![CDATA[
                try {
                    Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
                }
                catch  {
                }
            ]]>
            </Code>
        </Task>
    </UsingTask>
Run Code Online (Sandbox Code Playgroud)

我已将nuget.exe更新为最新版本,并且未在nuget.targets中更改任何内容.

Pou*_*sen 12

问题是解决方案中的某些类库具有默认值:

ToolsVersion="12.0"
Run Code Online (Sandbox Code Playgroud)

改变为

ToolsVersion="4.0"
Run Code Online (Sandbox Code Playgroud)

使它在TFS在线工作

  • 项目的csproj文件 (3认同)