| 1297 | // Resolve devenv.exe for a VS major-version range via vswhere; canonical Microsoft recipe. |
| 1298 | FString FindDevEnv(const char* VersionRange) |
| 1299 | { |
| 1300 | const char* VsWhereCandidates[] = |
| 1301 | { |
| 1302 | R"(C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe)", |
| 1303 | R"(C:\Program Files\Microsoft Visual Studio\Installer\vswhere.exe)", |
| 1304 | }; |
| 1305 | |
| 1306 | for (const char* Candidate : VsWhereCandidates) |
| 1307 | { |
| 1308 | if (!Filesystem::Exists(Candidate)) |
| 1309 | { |
| 1310 | continue; |
| 1311 | } |
| 1312 | |
| 1313 | FString Args = "-latest -products * -version \""; |
| 1314 | Args += VersionRange; |
| 1315 | Args += "\" -property productPath -nologo"; |
| 1316 | |
| 1317 | FString FirstLine; |
| 1318 | const int ExitCode = Platform::RunProcessAndWaitCapture( |
| 1319 | UTF8_TO_TCHAR(Candidate), UTF8_TO_TCHAR(*Args), nullptr, |
| 1320 | [&FirstLine](FStringView Line) |
| 1321 | { |
| 1322 | if (FirstLine.IsEmpty() && !Line.IsEmpty()) |
| 1323 | { |
| 1324 | FirstLine = FStringView(Line.GetData(), Line.Len()); |
| 1325 | } |
| 1326 | }); |
| 1327 | |
| 1328 | if (ExitCode == 0 && !FirstLine.IsEmpty()) |
| 1329 | { |
| 1330 | return FirstLine; |
| 1331 | } |
| 1332 | } |
| 1333 | return FString(); |
| 1334 | } |
| 1335 | |
| 1336 | FString FindVSCode() |
| 1337 | { |
| 1338 | TVector<FString> Candidates; |
| 1339 | const FString LocalAppData = Platform::GetEnvVariable("LOCALAPPDATA"); |
| 1340 | if (!LocalAppData.IsEmpty()) |
| 1341 | { |
| 1342 | Candidates.Emplace(LocalAppData + R"(\Programs\Microsoft VS Code\Code.exe)"); |
| 1343 | } |
| 1344 | Candidates.Emplace(R"(C:\Program Files\Microsoft VS Code\Code.exe)"); |
| 1345 | |
| 1346 | for (const FString& Candidate : Candidates) |
| 1347 | { |
| 1348 | if (Filesystem::Exists(Candidate)) |
| 1349 | { |
| 1350 | return Candidate; |
| 1351 | } |
| 1352 | } |
| 1353 | return FString(); |
| 1354 | } |
| 1355 | |
| 1356 | FString FindRider() |
nothing calls this directly
no test coverage detected