Fabian
Fabian

Reputation: 2000

Finding all the visual studio projects a file belongs to

I'm working on a visual studio solution with over 30 projects and multiple filters.

What is the easiest way to determine all the projects a file belongs too?

Upvotes: 4

Views: 3053

Answers (2)

st_stefanov
st_stefanov

Reputation: 1186

Use AgentRansack or similar tool that allows searching text contained in a file.

Use the following settings: File Name: *.csproj Containing Text: YourCodeFile.cs Look in: YourSolutionFolder

Run the search and you will get a list of all project files that are holders of the CS file.

Upvotes: 0

Doc Brown
Doc Brown

Reputation: 20054

First, open a command shell window and create a list of all project files in a text file. For example, for C# projects (having the ending .csproj), run this command in the root folder of your solution:

dir /s /b *.csproj >projectlist.txt

Then, you can easily determine all projects containing a specific file by the command

findstr /f:projectlist.txt /m Name_Of_Your_File

Just a suggestion: you can avoid much trouble for the future if you make sure each project has it's own folder, and all files belonging to that project are in or below that folder.

Upvotes: 6

Related Questions