realvizu/NsDepCop

VS 2015 - Dont see NsDepCop work in my project

Closed this issue ยท 14 comments

Hi,
I use VS2015 and 4.6 based projects.

I followed everything listed under https://github.com/realvizu/NsDepCop
and installed the .vsx plugin, but I dont see any log or warning from NsDepCop could you point me to an example solution or something I can try it to rule out any of my config issues?

Sure, see https://github.com/realvizu/NsDepCop/blob/master/source/config.nsdepcop for a solution level config and https://github.com/realvizu/NsDepCop/blob/master/source/NsDepCop.Core/config.nsdepcop for a project level config.

Is NsDepCop working when you build the project?
Can you post your config.nsdepcop so I can take a look?

I added manually, heres the default file that I added by going to Add > New Item

<!-- Any namespace can reference the System namespace and its sub-namespaces. -->
<Allowed From="*" To="System.*" />

<!-- Any namespace can reference the global namespace. -->
<Allowed From="*" To="." />

<!-- Code generated from XAML files can reference any namespace. -->
<Allowed From="XamlGeneratedNamespace" To="*" />

No NsDepCop is not working when I build the project. I guess my question is how do I make it work?
Per https://github.com/realvizu/NsDepCop/blob/master/doc/Troubleshooting.md#item4, I tried to configure but I dont even have a Custom.After.Microsoft.CSharp.targets under "(Program Files folder)\MsBuild\v14.0"
I did try to change Microsoft.Common.CurrentVersion.targets under "(Program Files folder)\MsBuild\v14.0\Bin" and that came with the error saying my project didnt have NsDepCop, while I clearly had added one. Heres my project.json
{
"version": "1.0.0-*",

"dependencies": {
"NETStandard.Library": "1.6.0",
"NsDepCop": "1.7.1"
},

"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}

Please set MSBuild output verbosity to detailed level and send me a build log so I can see what's going on.

Btw https://github.com/realvizu/NsDepCop/blob/master/doc/Troubleshooting.md#item4 does not apply to your case. It was about an older version before the NuGet package distribution that modified Custom.After.Microsoft.CSharp.targets. I'll clarify it in the doc.

BuildLog.txt

Attached please see the log file

Ah, now I see, so it's a project with an xproj project file.
Sorry, NsDepCop does not support that, only csproj files.
(In fact, I've just realized that their was such project type.)
I'll add that to the doc.

Does that mean NsDepCop doesnt work on projects created using VS 2015?

No. The problem is not VS 2015 but the xproj project type.

As far as I know, "ASP.NET 5" project is the only one that uses xproj.
And xproj project type is deprecated by Microsoft.
See: https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/

You have a couple of options:

Got it. I have it working at build time in VS2017.

Though I have the .vsx installed, I dont see a squiggly on namespaces violation at design time.
Am I still missing something.

Thanks!

There are different .vsx versions for VS 2015 and VS 2017.
Did you install the one for VS 2017?
https://marketplace.visualstudio.com/items?itemName=FerencVizkeleti.NsDepCopVS2017-CodedependencycheckerforC

Yes, I installed NsDepCop_VS2017-1.7.0.vsix (and NsDepCop_ConfigSchema-1.7.0.vsix) the schema validation worked but I don't see any effect of NsDepCop_VS2017-1.7.0.vsix

No idea, never got such error report.

Maybe try the following.

  1. Make sure that the files that you expect to give NsDepCop notifications otherwise compile correctly (no C# compiler errors). Because if the C# compiler cannot parse the file completely then NsDepCop may be unable to get type information from the parser.
  2. Make sure that the NsDepCop extension is enabled. Visual Studio may have disabled it for some reason. Go to Visual Studio > Tools > Extension and Updates > Find "NsDepCop VS2017" and make sure it is enabled.
  3. Check the Visual Studio ActivityLog to see if there were any problems with the NsDepCop extension. Here's a guide how to do it. A bit old so the path should be corrected for VS 2017. https://blogs.msdn.microsoft.com/visualstudio/2010/02/24/troubleshooting-extensions-with-the-activity-log/
  4. You can try to diagnose NsDepCop VSX using the DebugView utility.
  • Download from here: https://docs.microsoft.com/en-us/sysinternals/downloads/debugview
  • Start DebugView
    • Go to Edit > Filter/Highlight dialog. Set Include to this string: "[NsDepCop]" (without the quote marks).
    • Make sure that in the Capture menu the Capture Events menu item is selected (has a check mark).
  • Start Visual Studio 2017 and load a project that has NsDepCop added and make sure that this project gives NsDepCop notification when you build the project.
  • Open those files of the project in the code editor that contain the problems reported by NsDepCop at build time.
  • Check the DebugView tool if you can see any output from NsDepCop. If so then copy them to a text file and send them to me.

uninstall/reinstall the vsix files did the trick in 2017. Thanks for the wonderful tips.