5

I am writing a tool which inspects my source tree looking for .vcproj and .csproj projects (VS2005). I want it to know if each project is an application, DLL or static lib project.

For C#, I think this question has an answer ( How do you tell the Visual Studio project type from an existing Visual Studio project ) but I can't find an obvious parallel in C++ projects. I prefer something I can use as a simple search term in the text if possible.

Community
  • 1
  • 1
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • In 2012 it's `Application`, in `PropertyGroup` with `Label = "Configuration"`. Note that it may change depending on which project configuration is selected - so you have to be able to choose appropriate one. – Bartek Banachewicz Jan 16 '13 at 12:43
  • 2
    I'm pretty sure they changed things quite a lot in 2010 for C++ – Mr. Boy Jan 16 '13 at 14:01
  • To double check whatever solution you utilize, you can verify a given project type by right-clicking the project, selecting `Properties`->`Configuration Properties`->`General`->`Configuration Type` (Under "Project Defaults). – bunkerdive Sep 09 '15 at 12:09

1 Answers1

5

You'll need to parse the "ConfigurationType" attribute in the .vcproj file. An attribute of the <VisualStudioProject><Configurations><Configuration> element. It is "2" for a DLL project, "4" for a static library project. Beware that different configurations can have different values for this attribute, albeit that this will be very unusual.

You in general reverse-engineer these things by making a copy of the .vcproj file, make a change in the Project + Property pages, use File + SaveAll and then compare the two .vcproj files to see what changed.

Do watch out a bit for putting a lot of effort into such an old version of Visual Studio. Eight years is a very long time in software engineering, especially so after the C++11 standard was released. The C++ project file format dramatically changed at VS2010, now a .vcxproj file that joined the rest of the languages in VS by supporting builds through MSBuild. You are bound to have to redo all this when you upgrade your VS version some day. Better do that now since it sure won't be any easier doing it later when you came to depend on your tool.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Updating is driven by external factors, so in this case it's fine to add "update this little utility" to the _long_ list of testing when we one day move up to 2010 or beyond :) – Mr. Boy Jan 16 '13 at 16:55
  • ConfigurationType="1" is for application or exe project. – Nathan Feb 11 '14 at 16:22