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?
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.
Scan the directory structure for the files of interest. Keep their paths in a list in memory.
Open each file, reading the entire contents in to memory.
Find all GUIDs with the regular expression you've crafted.
For each GUID encountered check if you've already got a replacement GUID in a Dictionary -- the dictionary maps old GUID to new GUID.
If you have a replacement already, replace all instances of the Guid in the text.
If you don't have a replacement, generate one, store it in the dictionary and then replace all instances with the new one.
Write the changed contents of the file.
That's the long and short of it. I hope that helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With