Execute external tool\script when building the project in Ranorex Studio

Ranorex Studio, Spy, Recorder, and Driver.
andrii.savka
Posts: 21
Joined: Mon Mar 30, 2020 2:10 pm

Execute external tool\script when building the project in Ranorex Studio

Post by andrii.savka » Wed May 12, 2021 1:47 pm

Hi,

We want to inspect our code using ReSharper command-line tools.
So we have created a PowerShell script that can execute it.
But we need to do it manually after we build the project.

We want to somehow execute the PowerShell script when we build the solution from Ranorex Studio (after the build action).

I found in options some external tools section, but I don't know if this could help:
2021-05-12_15-39-21.png
2021-05-12_15-39-21.png (21.79 KiB) Viewed 1053 times
Is it possible to configure Ranorex Studio to do it automatically after the build action was made?

Thanks in advance!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7425
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Execute external tool\script when building the project in Ranorex Studio

Post by odklizec » Thu May 13, 2021 9:56 am

Hi,

You can define pre/post build events in the project properties, as shown here:
BuildEvents.png
BuildEvents.png (47.54 KiB) Viewed 1045 times
Just right-click a project and form the appeared menu select Properties >> Build events tab. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andrii.savka
Posts: 21
Joined: Mon Mar 30, 2020 2:10 pm

Re: Execute external tool\script when building the project in Ranorex Studio

Post by andrii.savka » Thu May 13, 2021 6:05 pm

Hi odklizec,

I have tried to add a call of a bat file that would execute the PowerShell script with parameters.
But nothing happened when I had built a solution.
2021-05-13_19-58-33.png
2021-05-13_19-58-33.png (39.63 KiB) Viewed 1041 times

User avatar
Stub
Posts: 471
Joined: Fri Jul 15, 2016 1:35 pm

Re: Execute external tool\script when building the project in Ranorex Studio

Post by Stub » Fri May 14, 2021 8:31 am

What is the 'call' thing for? Just a full filename to the batch file should be sufficient. You can also increase MSBuild verbosity to see more output, which may help diagnose this post build step.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7425
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Execute external tool\script when building the project in Ranorex Studio

Post by odklizec » Fri May 14, 2021 8:53 am

Hi,

I just tried it and it definitely works. I guess the problem in your case is this...$(SolutionDir)
Just try to replace this 'variable' with absolute path.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Stub
Posts: 471
Joined: Fri Jul 15, 2016 1:35 pm

Re: Execute external tool\script when building the project in Ranorex Studio

Post by Stub » Fri May 14, 2021 9:41 am

$(SolutionDir) is fine, it's a well-known MSBuild variable. We do similar things in our Ranorex solutions e.g.:

Code: Select all

"$(TargetFrameworkSDKToolsDirectory)TlbImp.exe" parameters_go_here
You can acquire a list of MSBuild variables from Visual Studio easily enough, or gander the MSBuild output in a higher verbosity. I can't recall if SolutionDir has a trailing path separator on it or not.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7425
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Execute external tool\script when building the project in Ranorex Studio

Post by odklizec » Fri May 14, 2021 9:52 am

Hi Stub,

You are right. $(SolutionDir) works fine. So the problem must be in Andrii's bat/powershell.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

andrii.savka
Posts: 21
Joined: Mon Mar 30, 2020 2:10 pm

Re: Execute external tool\script when building the project in Ranorex Studio

Post by andrii.savka » Fri May 14, 2021 11:52 am

I have created a new project just for the check. As you can see no TEST value in build logs:
2021-05-14_13-49-26.png
2021-05-14_13-49-26.png (42.27 KiB) Viewed 1029 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7425
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Execute external tool\script when building the project in Ranorex Studio

Post by odklizec » Fri May 14, 2021 12:04 pm

I'm not quite sure that echo is displayed in output tab. Just create a simple test.cmd with single line notepad.exe. Then place this bat file to solution dir (where rxtst is located) and call it with this command in PostBuild action... "$(SolutionDir)test.cmd".
After build, notepad.exe should be started (as it does for me).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Stub
Posts: 471
Joined: Fri Jul 15, 2016 1:35 pm

Re: Execute external tool\script when building the project in Ranorex Studio

Post by Stub » Fri May 14, 2021 2:37 pm

Have you adjusted the MSBuild output verbosity?

celalsur
Posts: 1
Joined: Fri Mar 04, 2022 7:06 am
Contact:

Re: Execute external tool\script when building the project in Ranorex Studio

Post by celalsur » Fri Mar 04, 2022 7:59 am

I'm also curious about MSBuild output verbosity