@@ -212,18 +212,6 @@ export class UnityEditor {
212212 throw Error ( 'No command arguments provided for Unity execution' ) ;
213213 }
214214
215- if ( command . projectPath ) {
216- if ( ! command . args . includes ( '-projectPath' ) ) {
217- command . args . unshift ( '-projectPath' , command . projectPath ) ;
218- } else {
219- const existingPath = GetArgumentValueAsString ( '-projectPath' , command . args ) ;
220-
221- if ( existingPath !== command . projectPath ) {
222- throw Error ( `Conflicting project paths provided. Argument: "${ existingPath } ", Command: "${ command . projectPath } "` ) ;
223- }
224- }
225- }
226-
227215 if ( ! command . args . includes ( '-logFile' ) ) {
228216 command . args . unshift ( '-logFile' , this . GenerateLogFilePath ( command . projectPath ) ) ;
229217 }
@@ -242,6 +230,22 @@ export class UnityEditor {
242230 command . args . unshift ( `-automated` ) ;
243231 }
244232
233+ if ( command . projectPath ) {
234+ if ( ! command . args . includes ( '-projectPath' ) ) {
235+ command . args . unshift ( '-projectPath' , command . projectPath ) ;
236+ } else {
237+ const existingPath = GetArgumentValueAsString ( '-projectPath' , command . args ) ;
238+
239+ if ( existingPath !== command . projectPath ) {
240+ throw Error ( `Conflicting project paths provided. Argument: "${ existingPath } ", Command: "${ command . projectPath } "` ) ;
241+ }
242+
243+ // Ensure -projectPath is the first argument
244+ command . args . splice ( command . args . indexOf ( existingPath ) , 1 ) ;
245+ command . args . unshift ( '-projectPath' , command . projectPath ) ;
246+ }
247+ }
248+
245249 const logPath : string = GetArgumentValueAsString ( '-logFile' , command . args ) ;
246250 logTail = TailLogFile ( logPath ) ;
247251 const commandStr = `\x1b[34m${ this . editorPath } ${ command . args . join ( ' ' ) } \x1b[0m` ;
0 commit comments