How to insert StyleCop into a solution?

I am trying to integrate StyleCop into a Visual Studio solution. Installing StyleCop on every machine of every developer is something I would rather avoid. The sentence that I saw several times ( example ) should include StyleCop binaries in the project, keeping them in version control.

I have done it. It works on my machine, but does not work on another machine where StyleCop is not installed. After uninstalling StyleCop on my machine, it doesn't work either.

The error message is as follows:

Severity Code Description Project file line Error The task "StyleCopTask" cannot be loaded from the assembly C: \ Program Files (x86) \ MSBuild .. \ StyleCop 4.7 \ StyleCop.dll. Failed to load file or assembly file: /// C: \ Program Files (x86) \ StyleCop 4.7 \ StyleCop.dll or one of its dependencies. The system cannot find the specified file. Ensure that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains an open class that implements Microsoft.Build.Framework.ITask. Demo

This is what I included in every .csproj file:

<Import Project="$(SolutionDir)\externs\Microsoft.StyleCop\StyleCop.targets" />

The catalog C:\demo\externs\Microsoft.StyleCopcontains:

  • Copy of all files from C:\Program Files (x86)\StyleCop 4.7,

  • Copy C:\Program Files (x86)\MSBuild\StyleCop\v4.7\StyleCop.Targets.

What's wrong?

+4
source share
1 answer

, StyleCop.Targets :

<UsingTask
    AssemblyFile="$(MSBuildExtensionsPath)\..\StyleCop 4.7\StyleCop.dll"
    TaskName="StyleCopTask"/>

StyleCop , , :

<UsingTask
    AssemblyFile="$(SolutionDir)\externs\Microsoft.StyleCop\StyleCop.dll"
    TaskName="StyleCopTask"/>
+4

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


All Articles