@@ -1590,6 +1590,13 @@ class MSVCProjectExporterBase : public ProjectExporter
15901590 bool launchProject () override
15911591 {
15921592 #if JUCE_WINDOWS
1593+ // Don't launch if already open
1594+ if (getSLNFile ().getSiblingFile (" .vs" ).findChildFiles (File::findFiles, true , " *.opendb" , File::FollowSymlinks::no).size () > 0 )
1595+ return false ;
1596+
1597+ if (launchViaVSWhere ())
1598+ return true ;
1599+
15931600 return getSLNFile ().startAsProcess ();
15941601 #else
15951602 return false ;
@@ -1704,6 +1711,41 @@ class MSVCProjectExporterBase : public ProjectExporter
17041711 : CppTokeniserFunctions::addEscapeChars (rebasedPath).quoted ();
17051712 }
17061713
1714+ bool launchViaVSWhere ()
1715+ {
1716+ auto vswhere = juce::File::getSpecialLocation (juce::File::globalApplicationsDirectoryX86).getChildFile (" Microsoft Visual Studio\\ Installer\\ vswhere.exe" );
1717+ if (! vswhere.existsAsFile ())
1718+ return false ;
1719+
1720+ juce::ChildProcess proc;
1721+ proc.start ({vswhere.getFullPathName (), " -format" , " json" });
1722+ proc.waitForProcessToFinish (1000 );
1723+
1724+ auto json = JSON::parse (proc.readAllProcessOutput ());
1725+ if (! json.isArray ())
1726+ return false ;
1727+
1728+ for (auto ver : *json.getArray ())
1729+ {
1730+ if (! ver.isObject ())
1731+ continue ;
1732+
1733+ auto catalog = ver.getProperty (" catalog" , {});
1734+ if (catalog.isObject ())
1735+ {
1736+ if (catalog.getProperty (" buildVersion" , {}).toString ().startsWith (juce::String (getVisualStudioVersion ())))
1737+ {
1738+ auto vs = File (ver.getProperty (" productPath" , {}).toString ());
1739+ if (vs.existsAsFile ())
1740+ if (vs.startAsProcess (getSLNFile ().getFullPathName ().quoted ()))
1741+ return true ;
1742+ }
1743+ }
1744+ }
1745+
1746+ return false ;
1747+ }
1748+
17071749protected:
17081750 // ==============================================================================
17091751 mutable File rcFile, iconFile, packagesConfigFile;
0 commit comments