The task cannot be loaded from the assembly.

I have a mistake in one of my projects at work. The error says:

Severity code Description Project file line suppression status Error The task "StyleCopTask" cannot be loaded from the assembly C: \ Projects \ Project Name \ Source \\ MSBuild \ StyleCop \ v4.7 \ StyleCop.dll. Could not load the file or assembly 'Microsoft.Build.Utilities.v3.5, Version = 3.5.0.0, Culture = Neutral, PublicKeyToken = b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the specified file. Confirm this statement true that the collection and all its dependencies are available and that the task contains an open class that implements Microsoft.Build.Framework.ITask. DskDirectMarketing.Common

Here, I clearly see that there is a problem in the relative path that VS is looking for StyleCop. Here's what it looks like:

<Import Project="$(SolutionDir)\MSBuild\StyleCop\v4.7\StyleCop.targets" />

and my SolutionDir declaration is as follows:

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

After some digging, I noticed that in the error that tells me there are 2 slashes:

C: \ Projects \ Project Name \ Source \ MSBuild \ StyleCop \ v4.7 \ StyleCop.dll

The first thing I tried was to remove the dash from

<Import Project="$(SolutionDir)MSBuild\StyleCop\v4.7\StyleCop.targets" />

Id did not work. After that, I tried to set the absolute path, but again I had 2 slashes.

How can I solve this problem? Any help would be appreciated.

+4
source share
2 answers

Based on @MaKCbIMKo answer, I installed the .NET Framework 3.5 and this fixed my problem.

+6
source

Windows 10, .net framework 3.5 , , :

Dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess
+1

Source: https://habr.com/ru/post/1661598/


All Articles