2

According to the docs I've read online all you need to do is add the following to the dependencies in project.json:

  "version": "1.0.0-*",

  "dependencies": {
    "DependencyA": "1.0.0-*",
    "DependencyB": "1.0.0-*",
    "StyleCop.Analyzers": {
      "version": "1.0.0",
      "type": "build"
    }
  },

  "frameworks": {
    "net46": { }
  }

(where DependencyA and DependencyB are two .NET Core projects from the same solution) and then StyleCop.Analyzers will run with the default rule set upon building the project. It doesn't. I get no warnings or anything and I'm pretty sure the code at the moment violates a lot of rules. Did anyone successfully get this working?

Tudor
  • 61,523
  • 12
  • 102
  • 142
  • I'm not sure why it wouldn't be working for you -- I tried to reproduce it in my answer below and couldn't. Maybe post your whole `project.json`? There could be something that's conflicting with StyleCop.Anaylzers. Just a guess. – Nate Barbettini Nov 03 '16 at 17:30

2 Answers2

1

My .NET Core version was apparently too old. After upgrading to the latest one it now works.

Tudor
  • 61,523
  • 12
  • 102
  • 142
0

I was able to get this working with Visual Studio 2015 Update 3 using the following steps:

  1. Create a new project from the ASP.NET Core Application (.NET Core) template.
  2. Add the StyleCop.Analyzers build dependency as you described in your question.
  3. Build the project in Visual Studio and make sure the Error List output is set to Build + IntelliSense.

This is what I get:

StyleCop warnings output

I've confirmed that this also works for projects targeting net451 instead of netcoreapp1.0, as well as Class Library projects targeting netstandard1.X.

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147