Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (45.3k points)

I am trying to build my project with visual studio online.

I am getting the following error:

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.

This is coming from the nuget.targets file in my solution.

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

I have updated nuget.exe to the latest and have not changed anything in nuget.targets.

1 Answer

0 votes
by (16.8k points)

Problem is that some of your class libraries in the solution are having the default value:

Change this ToolsVersion="12.0" to ToolsVersion="4.0".

It shall work.

Browse Categories

...