Temporary disable dependency validation in Visual Studio 2017

Viewed 943

I need to temporary disable the validation when I'm breaking unwanted dependencies in my solution because for some reason which is absolute mystery to me the dependency validation stops building dependent projects when it founds no dependencies declared for a specific project. I'd expect the validation to happen after building the whole solution but it's not the case.

Options that I've tried:

  1. Setting Build Action property on my main (the only actually) layer diagram in the dependencies project to None
  2. Excluding the dependencies project from the build in Configuration Manager
  3. Excluding the dependencies project from the solution (to include it back later if compilation is successful)

None of this works and that's killing me. How do I fix it?

2 Answers

Dependency validation in VS2017 is now carried out using Roslyn analyzers so you can turn the rules on and off and control the severity using rulesets, just like with any other Roslyn analyzer.

I'd expect the validation to happen after building the whole solution but it's not the case.

That's what used to happen prior to VS2017. Previously, validation was performed using a separate executable that was run after all of the other projects in the solution had been built.

Switching to using Roslyn analyzers means each project is validated as it is built. It also means that if a project isn't compiled (e.g. because MSBuild sees that no files have changed), then the analyzers won't be called so no errors will be reported.

To guarantee seeing all errors when building outside the IDE, you would have to rebuild i.e. msbuild /t:rebuild To see all errors when working in the IDE, turn on the Roslyn full solution analysis option.

There's more detail on the changes between VS2015 and VS2017 in this blog post.

Related