简体   繁体   中英

Temporary disable dependency validation in Visual Studio 2017

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?

You can disable it by going to Tools -> Options -> Dependency Validation at there you can set it to False through finding the required language.


And If some how you want to enable it then go to and check Tools -> Options -> Text Editor -> C# -> Advance -> Enable full solution analysis .

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 (eg 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 ie 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM