How can I determine which Visual Studio solutions projects use?

I have a software project that consists of several project files and several decision files. Decision files have a one-to-many relationship with project files, and a given project file can appear in several different decision files.

Is there any good / easy way to create a map of the relationship between solution files and project files? Either through VS, or some kind of utility.

What I would like to do is say: "Hey, there are several solution files and project files in this directory and its subdirectories - please tell me which solutions are used, which projects to display for me"

I understand that a pure effect can be obtained by opening every solution file and checking it, but I am looking for an automatic repetitive action.

EDIT: I'm afraid I also have Solution / Project commutes related to VS2003, so I also need to map them.

+5
source share
3 answers

Both project files and decision files are text files. Project files do not know about their solution, so we will have to look for solutions for our projects.

The project entry in the solution file is as follows:

Project("{9AC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProjectName", "ProjectDirectory\ProjectFileName.vcproj","{9A95F635-B74F-4640-BBCF-E324D0972CA9}"
EndProject

So, you can see, we can capture the project name and the relative path to the project file.

Using your favorite scripting language, you can do something like the following. (Example in ruby)

require 'find'

def project_name(string)
  string =~ /= "(.+?)"/
  $1
end

#the script doesn't use this method but you may want it
def project_path(string)
  string =~ /, "(.+?)"/
  $1
end

def find_projects(path)
  puts "#{path} contains the following projects:"
  open(path).read.gsub(/Project\(.+?EndProject/m) do |match|
    puts project_name(match)
  end
  puts ""
end

#change File.dirname(__FILE__)) to the name of the directory you want to search.
Find.find(File.dirname(__FILE__)) do |path|
  if FileTest.directory?(path)
    if File.basename(path) =~ /^\../ # Directory name starts with .
      Find.prune       # Don't look any further into this directory.
    else
      next
    end
  elsif path =~ /\.sln$/
    find_projects(path)
  end
end
+1

Gordon Wilson # QuickGraph GraphViz, , .

QuickGraph , Graphviz . , .

** ** . , , , . , , , . , , , .

+3

python (perl?) script .
GUID. - GUID .

0

All Articles