Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a tool for detecting Visual Studio projects with duplicate GUIDs?

When creating new Visual Studio C++ projects there're two ways: either run the wizard and then painfully change all the necessary settings in the project or just copy and existing project, rename everything there and add files into it.

The second variant is great except that the .vcproj file stores a project GUID. This GUID is used to track project dependencies and the startup project when two or more projects are in one solution. If any two projects in one solution have identical GUIDs problems can arise - dependencies are lost and the startup prject is reset on next solution reload.

Clearly there's a need for a tool that would scan the filesystem subtree and detect projects with identical GUIDs here. Before I start writing one ... is there a ready tool for that?

like image 515
sharptooth Avatar asked Nov 14 '22 14:11

sharptooth


1 Answers

You can write the tool relatively quickly. I've done so for my employer but they're stingy with code. Detecting a GUID is "easy" when using regular expression.

  1. Scan the directory structure for the files of interest. Keep their paths in a list in memory.

  2. Open each file, reading the entire contents in to memory.

  3. Find all GUIDs with the regular expression you've crafted.

  4. For each GUID encountered check if you've already got a replacement GUID in a Dictionary -- the dictionary maps old GUID to new GUID.

    1. If you have a replacement already, replace all instances of the Guid in the text.

    2. If you don't have a replacement, generate one, store it in the dictionary and then replace all instances with the new one.

  5. Write the changed contents of the file.

That's the long and short of it. I hope that helped.

like image 193
Jason D Avatar answered Dec 30 '22 17:12

Jason D