Is there a tool for detecting Visual Studio projec

2019-06-26 02:27发布

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?

2条回答
在下西门庆
2楼-- · 2019-06-26 02:54

You can try playing around with this tool. It's designed to merge/relocate solutions but as a bonus it can detect and regenerate duplicate guids across multiple solutions/projects.

http://code.google.com/p/merge-solutions/

查看更多
相关推荐>>
3楼-- · 2019-06-26 02:57

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.

查看更多
登录 后发表回答