@@ -187,6 +187,12 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings
187187 setRelativePaths (filename);
188188 return ImportProject::Type::VS_SLN;
189189 }
190+ }
191+ else if (endsWith (filename, " .slnx" )) {
192+ if (importSlnx (filename, fileFilters)) {
193+ setRelativePaths (filename);
194+ return ImportProject::Type::VS_SLNX;
195+ }
190196 } else if (endsWith (filename, " .vcxproj" )) {
191197 std::map<std::string, std::string, cppcheck::stricmp> variables;
192198 std::vector<SharedItemsProject> sharedItemsProjects;
@@ -488,6 +494,54 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const
488494 return true ;
489495}
490496
497+ bool ImportProject::importSlnx (const std::string& filename, const std::vector<std::string>& fileFilters)
498+ {
499+ tinyxml2::XMLDocument doc;
500+ const tinyxml2::XMLError error = doc.LoadFile (filename.c_str ());
501+ if (error != tinyxml2::XML_SUCCESS) {
502+ errors.emplace_back (std::string (" Visual Studio project file is not a valid XML - " ) + tinyxml2::XMLDocument::ErrorIDToName (error));
503+ return false ;
504+ }
505+
506+ const tinyxml2::XMLElement* const rootnode = doc.FirstChildElement ();
507+ if (rootnode == nullptr ) {
508+ errors.emplace_back (" Visual Studio project file has no XML root node" );
509+ return false ;
510+ }
511+
512+ std::map<std::string, std::string, cppcheck::stricmp> variables;
513+ variables[" SolutionDir" ] = Path::simplifyPath (Path::getPathFromFilename (filename));
514+
515+ bool found = false ;
516+ std::vector<SharedItemsProject> sharedItemsProjects;
517+
518+ for (const tinyxml2::XMLElement* node = rootnode->FirstChildElement (); node; node = node->NextSiblingElement ()) {
519+ const char * name = node->Name ();
520+ if (std::strcmp (name, " Project" ) == 0 ) {
521+ const char * labelAttribute = node->Attribute (" Path" );
522+ if (labelAttribute) {
523+ std::string vcxproj (labelAttribute);
524+ vcxproj = Path::toNativeSeparators (std::move (vcxproj));
525+ if (!Path::isAbsolute (vcxproj))
526+ vcxproj = variables[" SolutionDir" ] + vcxproj;
527+ vcxproj = Path::fromNativeSeparators (std::move (vcxproj));
528+ if (!importVcxproj (vcxproj, variables, " " , fileFilters, sharedItemsProjects)) {
529+ errors.emplace_back (" failed to load '" + vcxproj + " ' from Visual Studio solution" );
530+ return false ;
531+ }
532+ found = true ;
533+ }
534+ }
535+ }
536+
537+ if (!found) {
538+ errors.emplace_back (" no projects found in Visual Studio solution file" );
539+ return false ;
540+ }
541+
542+ return true ;
543+ }
544+
491545namespace {
492546 struct ProjectConfiguration {
493547 explicit ProjectConfiguration (const tinyxml2::XMLElement *cfg) {
0 commit comments