Pregunta

In Visual Studio, for a class, a field, a method, I can just right click and say "Find All References" to see who is calling my code.

But there is no similar thing for a project.

What is the simplest way to do so? Do I have to check every project to tell?

Edit: enter image description here

A refers to B, but can not find B using Regex.

¿Fue útil?

Solución

  1. Find All (CTRL+SHIFT+F)
  2. "Find what:" = Reference.*ReplaceThisTextWithProjectName
  3. Check "Use:" -> "Regular Expression" in the "Find options" section
  4. "Look at these file types:" = "*.*proj* "
  5. "Look in:" = Select a directory/folder on your drive. Don't use "Entire Solution" it won't get to the project file itself. (Don't forget to check "Include sub-folders")

Otros consejos

Not sure if you've looked into using Resharper (not free), but it easily allows you to right-click on a project to see dependent code.

I can't live without and well worth the cost in my opinion - but it's not for everyone.

http://www.jetbrains.com/resharper/webhelp/Navigation_and_Search__Finding_Usages__Finding_Dependencies_and_Referenced_Code.html

There's a 30 day trial if you want to try it out - P.S I don't work for them, just a lover of the tool! :)

http://www.jetbrains.com/resharper/

Search all Project Files in editor like Notepad++

A similar approach to fenone's answer is to go to your solution folder in Windows and simply filter on *.*proj there through Windows search. That'll give you all your project files (or maybe you have some in a different folder, they can be added later). Simply select all these files and open in an editor like Notepad++. You can add other projects to your Notepad++ instance as desired. Once you've got your project files all opened there, it's easy to search for references to projects, .dlls, libraries, whatever. I prefer this approach because the project files are off in their own editor and they are easier to search in my opinion.

Unload Project and Recompile

A second approach would be to right click your project in Visual Studio's Solution Explorer and click "Unload Project", then analyze or recompile the solution. Any projects that actual reference the unloaded project in code will have errors, but your build will still be successful and your project level references will still show as being valid (at least they are for me in VS 2017). A similar more invasive approach that invalidates project level references and actually fails any referencing build would be to change your project folder's path so that Visual Studios can't find it. This would have the secondary affect of also identifying any references setup by path instead of by project.

Other Considerations

Of course, your project could be included in other solutions, so similar search techniques can be used across solutions. Just to cover your bases, there might be references to your compiled file by path instead of by project, that's just something to be aware of. Check you post-build events to make sure nothing is being copied and referenced somewhere unexpected. Search for all instances of your .dll or whatever in some reasonable folder scope, just to be aware of any copies.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top