Skip to content

Commit 3448f30

Browse files
committed
V0.98.0
- Android Studio exec open all platforms - Visual Studio determine target SLN and open version 2022 if target or 2019 if target. Fixes VS2019 installed opening by default
1 parent ceb5b22 commit 3448f30

File tree

2 files changed

+90
-10
lines changed

2 files changed

+90
-10
lines changed

commandLine/src/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
2-
#define OFPROJECTGENERATOR_MINOR_VERSION "97"
2+
#define OFPROJECTGENERATOR_MINOR_VERSION "98"
33
#define OFPROJECTGENERATOR_PATCH_VERSION "0"
44

55
#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)

frontend/index.js

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,74 @@ ipcMain.on('checkMultiUpdatePath', (event, arg) => {
11981198
}
11991199
});
12001200

1201+
function getVisualStudioPath(version) {
1202+
return new Promise((resolve, reject) => {
1203+
exec(`"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" -latest -prerelease -format json`, (error, stdout, stderr) => {
1204+
if (error) {
1205+
reject("vswhere.exe not found. Ensure Visual Studio is installed.");
1206+
return;
1207+
}
1208+
1209+
try {
1210+
const installations = JSON.parse(stdout);
1211+
const vsInstall = installations.find(install =>
1212+
install.displayName.includes("Visual Studio") && install.catalog.productDisplayVersion.startsWith(version)
1213+
);
1214+
1215+
if (vsInstall) {
1216+
resolve(path.join(vsInstall.installationPath, "Common7", "IDE", "devenv.exe"));
1217+
} else {
1218+
reject(`No Visual Studio ${version} installation found.`);
1219+
}
1220+
} catch (parseError) {
1221+
reject("Error parsing vswhere output.");
1222+
}
1223+
});
1224+
});
1225+
}
1226+
1227+
async function openVisualStudio(windowsPath) {
1228+
console.log(`Opening project: ${windowsPath} in ${platform}`);
1229+
1230+
if (platform === 'vscode') {
1231+
console.log("Opening in VS Code...");
1232+
exec(`code "${windowsPath}"`, (error, stdout, stderr) => {
1233+
if (error) {
1234+
console.error("Could not open VS Code:", stderr);
1235+
console.log("Falling back to system handler...");
1236+
exec(`start "" "${windowsPath}"`);
1237+
}
1238+
});
1239+
return;
1240+
}
1241+
1242+
let isVS2019Project = false;
1243+
const solutionFile = path.join(path.dirname(windowsPath), path.basename(windowsPath));
1244+
1245+
if (fs.existsSync(solutionFile)) {
1246+
const fileContent = fs.readFileSync(solutionFile, 'utf8');
1247+
if (fileContent.includes("VisualStudioVersion = 16.0")) {
1248+
isVS2019Project = true;
1249+
}
1250+
}
1251+
1252+
try {
1253+
if (isVS2019Project) {
1254+
console.log("Detected VS2019 project, searching for VS2019 installation...");
1255+
const vs2019Path = await getVisualStudioPath("16");
1256+
exec(`"${vs2019Path}" "${windowsPath}"`);
1257+
} else {
1258+
console.log("Opening in VS2022 by default...");
1259+
const vs2022Path = await getVisualStudioPath("17");
1260+
exec(`"${vs2022Path}" "${windowsPath}"`);
1261+
}
1262+
} catch (error) {
1263+
console.error("Could not open Visual Studio:", error);
1264+
console.log("Falling back to default system handler...");
1265+
exec(`start "" "${windowsPath}"`);
1266+
}
1267+
}
1268+
12011269
ipcMain.on('launchProjectinIDE', (event, arg) => {
12021270
const {
12031271
projectPath,
@@ -1243,12 +1311,27 @@ ipcMain.on('launchProjectinIDE', (event, arg) => {
12431311
}
12441312
} else if( arg.platform == 'android'){
12451313
console.log("Launching ", fullPath)
1246-
exec('studio ' + fullPath, (error, stdout, stderr) => {
1247-
if(error){
1314+
console.log("Launching Android Studio at", fullPath);
1315+
let command;
1316+
1317+
if (os.platform() === 'darwin') { // macOS
1318+
command = `open -a "Android Studio" "${fullPath}"`;
1319+
} else if (os.platform() === 'linux') { // Linux
1320+
command = `studio "${fullPath}" || xdg-open "${fullPath}"`;
1321+
} else if (os.platform() === 'win32') { // Windows
1322+
command = `start "" "studio64.exe" "${fullPath}"`;
1323+
} else {
1324+
console.error("Unsupported OS for launching Android Studio");
1325+
return;
1326+
}
1327+
1328+
exec(command, (error, stdout, stderr) => {
1329+
if (error) {
1330+
console.error("Could not launch Android Studio:", stderr);
12481331
event.sender.send('sendUIMessage',
1249-
'<strong>Error!</strong><br>' +
1250-
'<span>Could not launch Android Studio. Make sure the command-line launcher is installed by running <i>Tools -> Create Command-line Launcher...</i> inside Android Studio and try again</span>'
1251-
);
1332+
'<strong>Error!</strong><br>' +
1333+
'<span>Could not launch Android Studio. Make sure the command-line launcher is installed by running <i>Tools -> Create Command-line Launcher...</i> inside Android Studio and try again.</span>'
1334+
);
12521335
}
12531336
});
12541337
} else if( hostplatform == 'windows'){
@@ -1257,12 +1340,9 @@ ipcMain.on('launchProjectinIDE', (event, arg) => {
12571340
if(arg.platform == 'vscode' ){
12581341
windowsPath = path.join(fullPath, projectName + '.code-workspace');
12591342
}
1260-
12611343
console.log( windowsPath );
12621344
windowsPath = "\"" + windowsPath + "\"";
1263-
exec('start ' + "\"\"" + " " + windowsPath, (error, stdout, stderr) => {
1264-
return;
1265-
});
1345+
openVisualStudio(windowsPath);
12661346
}
12671347
});
12681348

0 commit comments

Comments
 (0)