@@ -88,7 +88,8 @@ public int execute(@Nonnull String command, @Nonnull SerializableCliOptions opti
8888
8989 FilePath commandOptionsFile = remoteTempDir .createTextTempFile ("uipcliargs" , "" , new JSONObject (new RunOptions (command , options )).toString ());
9090
91- int result = launcher .launch ().cmds (this .buildCommandLine (cliPath , commandOptionsFile , envVars )).envs (envVars ).stdout (listener ).pwd (cliPath .getParent ()).start ().join ();
91+ String [] commandParams = new String []{"dotnet" , cliPath .getRemote (), "run" , commandOptionsFile .getRemote ()};
92+ int result = launcher .launch ().cmds (commandParams ).envs (envVars ).stdout (listener ).pwd (cliPath .getParent ()).start ().join ();
9293 if (throwExceptionOnFailure && result != 0 ) {
9394 throw new AbortException ("Failed to run the command, the CLI failed with error code " + result );
9495 }
@@ -123,7 +124,8 @@ public CliDetails getCliDetails(
123124
124125 StreamTaskListener execListener = new StreamTaskListener (commandOutput , run .getCharset ());
125126
126- launcher .launch ().cmds (this .buildVersionArgs (cliPath , envVars )).envs (envVars ).stdout (execListener ).pwd (cliPath .getParent ()).start ().join ();
127+ String [] commandParameters = new String [] {"dotnet" , cliPath .getRemote (), "--version" };
128+ launcher .launch ().cmds (commandParameters ).envs (envVars ).stdout (execListener ).pwd (cliPath .getParent ()).start ().join ();
127129
128130 String stdoutText = commandOutput .toString (run .getCharset ().name ());
129131
@@ -160,8 +162,8 @@ public void validateRuntime(@Nonnull Launcher launcher, @Nonnull EnvVars envVars
160162
161163 public FilePath extractCliApp (@ Nonnull FilePath targetRootCacheDir , @ Nonnull TaskListener listener , @ Nonnull EnvVars env ) throws IOException , InterruptedException , URISyntaxException {
162164 PrintStream logger = listener .getLogger ();
163- ResourceBundle rb = ResourceBundle . getBundle ( "config" );
164- FilePath targetCliPath = targetRootCacheDir . child ( "tools" ). child ( "uipcli.dll" );
165+ FilePath targetCliPath = getDotnetToolCliPath ( targetRootCacheDir );
166+
165167 if (targetCliPath .exists ())
166168 {
167169 logger .println ("Using previously extracted UiPath CLI from " + targetCliPath );
@@ -183,6 +185,29 @@ public FilePath extractCliApp(@Nonnull FilePath targetRootCacheDir, @Nonnull Tas
183185 return targetCliPath ;
184186 }
185187
188+ // With support for .NET tool structure, look for uipcli.dll in tools/netX.X/any/uipcli.dll. Maintain also backward compatibility.
189+ public static FilePath getDotnetToolCliPath (FilePath targetPath ) throws IOException , InterruptedException {
190+ FilePath uipcliToolPath ;
191+
192+ FilePath toolsDir = targetPath .child ("tools" );
193+ uipcliToolPath = toolsDir .child ("uipcli.dll" );
194+
195+ if (uipcliToolPath .exists ()) {
196+ return uipcliToolPath ;
197+ }
198+
199+ if (toolsDir .exists ()) {
200+ for (FilePath child : toolsDir .listDirectories ()) {
201+ String dirName = child .getName ();
202+ if (dirName .startsWith ("net" )) {
203+ uipcliToolPath = child .child ("any" ).child ("uipcli.dll" );
204+ break ;
205+ }
206+ }
207+ }
208+ return uipcliToolPath ;
209+ }
210+
186211 public void downloadCli (String feedUrl ,@ Nonnull FilePath downloadPath , @ Nonnull TaskListener listener ) throws AbortException {
187212 PrintStream logger = listener .getLogger ();
188213 logger .println ("Downloading CLI from " + feedUrl );
@@ -298,40 +323,6 @@ else if (strategy instanceof UnattendedJobTypeEntry)
298323 }
299324 }
300325
301- private String [] buildCommandLine (FilePath cliPath , FilePath commandOptionsFile , @ Nonnull EnvVars envVars ) throws JsonProcessingException {
302- UiPathCliConfiguration configuration = UiPathCliConfiguration .getInstance ();
303- String selectedCliVersionKey = envVars .get (UiPathCliConfiguration .SELECTED_CLI_VERSION_KEY );
304-
305- if (StringUtils .isBlank (selectedCliVersionKey )) {
306- selectedCliVersionKey = configuration .getDefaultCliVersionKey ();
307- }
308-
309- UiPathCliConfiguration .Configuration cliConfig = configuration .getConfiguration ().get (selectedCliVersionKey );
310-
311- if (cliConfig .getVersion ().getMajor () >= 22 ) {
312- return new String [] {"dotnet" , cliPath .getRemote (), "run" , commandOptionsFile .getRemote () };
313- }
314-
315- return new String [] { cliPath .getRemote (), "run" , commandOptionsFile .getRemote () };
316- }
317-
318- private String [] buildVersionArgs (FilePath cliPath , @ Nonnull EnvVars envVars ) throws JsonProcessingException {
319- UiPathCliConfiguration configuration = UiPathCliConfiguration .getInstance ();
320- String selectedCliVersionKey = envVars .get (UiPathCliConfiguration .SELECTED_CLI_VERSION_KEY );
321-
322- if (StringUtils .isBlank (selectedCliVersionKey )) {
323- selectedCliVersionKey = configuration .getDefaultCliVersionKey ();
324- }
325-
326- UiPathCliConfiguration .Configuration cliConfig = configuration .getConfiguration ().get (selectedCliVersionKey );
327-
328- if (cliConfig .getVersion ().getMajor () >= 22 ) {
329- return new String [] {"dotnet" , cliPath .getRemote (), "--version" };
330- }
331-
332- return new String [] { cliPath .getRemote (), "--version" };
333- }
334-
335326 private void extractResourcesToTempFolder (FilePath tempDir , File jarfile , TaskListener listener ) throws IOException , InterruptedException {
336327 try (JarFile archive = new JarFile (jarfile )) {
337328 // sort entries by name to always create folders first
0 commit comments