@@ -107,7 +107,8 @@ function getDefaultTemplateForPlatform(platformId) {
107107 "linux64" : "Linux 64 (VS Code/Make)" ,
108108 "linuxarmv6l" : "Arm 32 (VS Code/Make)" ,
109109 "linuxaarch64" : "Arm 64 (VS Code/Make)" ,
110- "vscode" : "VS Code"
110+ "vscode" : "VS Code" ,
111+ "vs2019" : "Windows (Visual Studio 2019)" ,
111112 } ;
112113
113114 return defaultTemplates [ platformId ] || "Unknown Template" ;
@@ -252,6 +253,8 @@ const templates = {
252253 "tvOS" : "Apple tvOS template" ,
253254 "unittest" : "Unit test no window application" ,
254255 "vscode" : "Visual Studio Code" ,
256+ "vs2019" : "Visual Studio 2019" ,
257+
255258} ;
256259
257260let defaultOfPath = settings [ "defaultOfPath" ] ;
@@ -888,7 +891,8 @@ function updateFunction(event, update) {
888891 }
889892
890893 if ( templateList != null ) {
891- templateString = `-t"${ templateList . join ( "," ) } "` ;
894+ const uniqueTemplates = [ ...new Set ( templateList ) ] ;
895+ templateString = `-t"${ uniqueTemplates . join ( "," ) } "` ;
892896 }
893897
894898 if ( ofPath != null ) {
@@ -1111,7 +1115,8 @@ ipcMain.on('pickUpdatePath', async (event, arg) => {
11111115 } ) ;
11121116 if ( filenames !== undefined && filenames . filePaths . length > 0 ) {
11131117 // defaultOfPath = filenames.filePaths[0]; // TODO: IS THIS CORRECT?
1114- event . sender . send ( 'setUpdatePath' , filenames . filePaths [ 0 ] ) ;
1118+ const formattedPath = process . platform === "win32" ? filenames . filePaths [ 0 ] . replace ( / \/ / g, "\\" ) : filenames . filePaths [ 0 ] ;
1119+ event . sender . send ( 'setUpdatePath' , formattedPath ) ;
11151120 }
11161121 } catch ( err ) {
11171122 console . error ( 'pickUpdatePath' , err ) ;
@@ -1133,7 +1138,8 @@ ipcMain.on('pickProjectPath', async (event, arg) => {
11331138 defaultPath : arg
11341139 } ) ;
11351140 if ( filenames !== undefined && filenames . filePaths . length > 0 ) {
1136- event . sender . send ( 'setProjectPath' , filenames . filePaths [ 0 ] ) ;
1141+ const formattedPath = process . platform === "win32" ? filenames . filePaths [ 0 ] . replace ( / \/ / g, "\\" ) : filenames . filePaths [ 0 ] ;
1142+ event . sender . send ( 'setProjectPath' , formattedPath ) ;
11371143 }
11381144 } catch ( err ) {
11391145 console . error ( 'pickProjectPath' , err ) ;
@@ -1240,29 +1246,47 @@ async function openVisualStudio(windowsPath) {
12401246 }
12411247
12421248 let isVS2019Project = false ;
1243- const solutionFile = path . join ( path . dirname ( windowsPath ) , path . basename ( windowsPath ) ) ;
1244-
1249+ const windowsPathEscaped = windowsPath . replace ( / \\ / g, '\\\\' ) ;
1250+ solutionFile = path . resolve ( windowsPath . trim ( ) . replace ( / ^ " + | " + $ / g, '' ) ) ;
1251+ console . log ( "VS Solution File Content: " + solutionFile ) ;
12451252 if ( fs . existsSync ( solutionFile ) ) {
12461253 const fileContent = fs . readFileSync ( solutionFile , 'utf8' ) ;
1247- if ( fileContent . includes ( "VisualStudioVersion = 16.0" ) ) {
1254+ if ( fileContent . match ( / V i s u a l S t u d i o V e r s i o n = 1 6 \. \d + / ) ) {
1255+ console . log ( "Detected VS2019!" ) ;
12481256 isVS2019Project = true ;
1257+ } else {
1258+ console . log ( "VS2019 Not Detected." ) ;
12491259 }
1260+ } else {
1261+ console . error ( "Error: Solution file does not exist: " + solutionFile ) ;
12501262 }
12511263
12521264 try {
12531265 if ( isVS2019Project ) {
1254- console . log ( "Detected VS2019 project, searching for VS2019 installation ..." ) ;
1266+ console . log ( "Detected VS2019 project, opening in VS2019..." ) ;
12551267 const vs2019Path = await getVisualStudioPath ( "16" ) ;
1256- exec ( `"${ vs2019Path } " "${ windowsPath } "` ) ;
1268+ const vs2019PathEscaped = vs2019Path . replace ( / \\ / g, '\\\\' ) ;
1269+ console . log ( `Opening in VS2022 by default.. path:[${ vs2019PathEscaped } ] command:start "" "${ vs2019PathEscaped } " "${ windowsPathEscaped } "` ) ;
1270+ exec ( `start "" "${ vs2019PathEscaped } " ${ windowsPathEscaped } ` , ( error , stdout , stderr ) => {
1271+ if ( error ) {
1272+ console . error ( "Error opening in VS2019:" , stderr ) ;
1273+ }
1274+ } ) ;
12571275 } else {
1258- console . log ( "Opening in VS2022 by default..." ) ;
12591276 const vs2022Path = await getVisualStudioPath ( "17" ) ;
1260- exec ( `"${ vs2022Path } " "${ windowsPath } "` ) ;
1277+ const vs2022PathEscaped = vs2022Path . replace ( / \\ / g, '\\\\' ) ;
1278+ console . log ( `Opening in VS2022 by default.. path:[${ vs2022PathEscaped } ] command:start "" "${ vs2022PathEscaped } " "${ windowsPathEscaped } "` ) ;
1279+ exec ( `start "" "${ vs2022PathEscaped } " ${ windowsPathEscaped } ` , ( error , stdout , stderr ) => {
1280+ if ( error ) {
1281+ console . error ( "Error opening in VS2022:" , stderr ) ;
1282+ }
1283+ } ) ;
1284+
12611285 }
12621286 } catch ( error ) {
12631287 console . error ( "Could not open Visual Studio:" , error ) ;
12641288 console . log ( "Falling back to default system handler..." ) ;
1265- exec ( ` start "" "${ windowsPath } "` ) ;
1289+ exec ( ' start "" "' + windowsPath + '"' ) ;
12661290 }
12671291}
12681292
0 commit comments