Skip to content

Commit f0fdc3a

Browse files
committed
reFX: Projucer: Launch correct VS version. Don't launch again if already running.
1 parent c57041e commit f0fdc3a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_MSVC.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
17071749
protected:
17081750
//==============================================================================
17091751
mutable File rcFile, iconFile, packagesConfigFile;

0 commit comments

Comments
 (0)