来自C#包装器的StyleCop未检测到冲突
我正在使用githubrepo尝试从CMD运行StyleCop。我下载了GitHub repo,并使用VS2017在本地机器上构建了它。我试图运行批处理脚本 这就是我到目前为止所做的:来自C#包装器的StyleCop未检测到冲突,c#,batch-file,cmd,stylecop,C#,Batch File,Cmd,Stylecop,我正在使用githubrepo尝试从CMD运行StyleCop。我下载了GitHub repo,并使用VS2017在本地机器上构建了它。我试图运行批处理脚本 这就是我到目前为止所做的: 以ZIP格式下载并解压缩到文件夹中 在VS2017中打开并构建了解决方案(无错误) 然后我尝试运行“sample.bat”(..\source\StyleCopCmdLine\bin\Debug\sample.bat),它执行以下操作(由源的所有者创建以测试repo): 加载源文件..\source\Sty
- 以ZIP格式下载并解压缩到文件夹中
- 在VS2017中打开并构建了解决方案(无错误)
- 加载源文件..\source\StyleCopWrapper.Tests\Testfiles\FileWith7Errors.cs
- 加载设置文件..\source\StyleCopWrapper.Tests\TestFiles\AllSettingsEnabled.StyleCop
C:\Users\X\Desktop\Test\StyleCopCmdLine-
master\source\StyleCopCmdLine\bin\Debug>Rem Runs the command line with
reasonable parameters
C:\Users\X\Desktop\Test\StyleCopCmdLine-
master\source\StyleCopCmdLine\bin\Debug>StyleCopCmdLine --
SourceFiles="..\..\..\StyleCopWrapper.Tests\TestFiles\FileWith7Errors.cs" --
s=@"..\..\..\StyleCopWrapper.Tests\TestFiles\AllSettingsEnabled.StyleCop"
StyleCopCmdLine 1.0.0.0
Copyright © 2017
-f, --SourceFiles Required. The files or folders to scan.
Multiple files or folders can be listed
-s, --SettingsFile Required. The settings to use.
--AdditionalAddInPaths (Default: System.String[]) The paths to
rules files. Multiple folders can be
listed
--ShowOutput (Default: False) Show the addin of files
to scan output in the log.
--CacheResults (Default: False) Cache scan results.
--XmlOutputFile (Default: .\stylecop.xml) Xml Output
File.
--LogFile (Default: .\stylecop.log) Log File.
--ForceFullAnalysis (Default: True) Force a full analysis.
--TreatViolationsErrorsAsWarnings (Default: True) Treat violation errors
as warnings.
--MaximumViolationCount (Default: 1000) Maximum violations
before the scan is stopped.
-v, --verbose (Default: True) Prints the configuration
messages to standard output.
--help Display this help screen.
SourceFiles: ..\..\..\StyleCopWrapper.Tests\TestFiles\FileWith7Errors.cs
SettingsFile:
@..\..\..\StyleCopWrapper.Tests\TestFiles\AllSettingsEnabled.StyleCop
MaximumViolationCount: 1000
ShowOutput: False
CacheResults: False
ForceFullAnalysis: True
XmlOutputFile: .\stylecop.xml
LogFile: .\stylecop.log
TreatViolationsErrorsAsWarnings: True
AdditionalAddInPaths: C:\Program Files (x86)\StyleCop 4.7
No violations encountered
Succeeded [True]
Violation count [0]
C:\Users\X\Desktop\Test\StyleCopCmdLine-master\source\StyleCopCmdLine\bin\Debug>pause
正如您所看到的,脚本没有返回冲突,但是当我打开StyleCopCmdLine解决方案时,导航到文件“FileWith7Errors”,右键单击并单击“runstylecop”,它返回7个冲突
我还尝试创建自己的StyleCop模块,该模块使用StyleCopConsole(来自官方的StyleCop repo),但是当我在任何有冲突的文件上运行它时(我确保选择了正确的设置文件),我从未得到任何冲突
删除C:\Program Files(x86)\StyleCop 4.7会得到完全相同的结果
我尝试过的其他回购协议要么出现错误,要么出现相同问题:
- StyleCopCLI
- StyleCopCmd
- 短跑运动员
- 样式控制台
编辑2-在我将所有源代码文件加载到StyleCop analyzer中,然后开始分析后,分析似乎运行了~,因此它没有正确运行分析的原因是因为我使用了加载项路径 初始化StyleCopConsole类时,需要以下参数:
StyleCopConsole(string settings,
bool writeResultsCache,
string outputFile,
ICollection<string> addInPaths,
bool loadFromDefaultPath);
然后StyleCopConsole将自己获得所有必要的DLL。
现在使用这些设置运行分析
var addInPath = @"C:\Program Files (x86)\StyleCop 4.7";