How to build Ranorex projects from the command line

Best practices, code snippets for common functionality, examples, and guidelines.
User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

How to build Ranorex projects from the command line

Post by Support Team » Fri Jan 07, 2011 10:26 am

A common task, e.g. when Ranorex is used with a Continuous Integration system, is that you need to compile your Ranorex tests from the test sources, i.e. the Ranorex projects. For example, when you have your Ranorex test sources checked into a source control system, you first update your test sources, compile the test projects to executables, and then run these test executables.

Ranorex Studio itself does not provide a command line interface, simply because the Ranorex project files are compatible with Visual Studio and MSBuild, which is installed as part of the .NET Framework. So you just have to use MSBuild and tell it to compile the Ranorex solution/project files:

Code: Select all

// solution
%WINDIR%\Microsoft.NET\Framework\v3.5\MSBuild.exe solution.sln
// C# project
%WINDIR%\Microsoft.NET\Framework\v3.5\MSBuild.exe project.csproj
// VBNet project
%WINDIR%\Microsoft.NET\Framework\v3.5\MSBuild.exe project.vbproj
You can also specify the configuration and platform to use by providing additional command line parameters. Please, see following page on MSDN for available command line parameters for MSBuild:
http://msdn.microsoft.com/library/ms164311.aspx

Just let me bring two facts to your attention that could cause problems:
  • All test source files need to be up-to-date when compiling test solutions/projects from the command line. For example, the source code for Ranorex recordings/repositories will not be updated!
  • MSBuild is confused by the "rxsln" ending of the solution file, that's why Ranorex Studio automatically saves the same file with a "sln" file ending as well. Please, always use the "sln" file or the individual project files when using MSBuild.
Regards,
Alex
Ranorex Team

anil13
Posts: 2
Joined: Thu Dec 04, 2014 8:15 am

Re: How to build Ranorex projects from the command line

Post by anil13 » Thu Dec 04, 2014 8:22 am

Hi Alex,
This does not seem to work.
I need to build a ranorex project which references other projects which in turn reference other projects.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to build Ranorex projects from the command line

Post by krstcs » Thu Dec 04, 2014 2:31 pm

It works fine for me. I do this all the time with multiple projects. All projects are in the same solution though. If it works in Ranorex Studio then it will work with MSBuid (since RXStudio uses MSBuild).

If by "project" you mean solution, then no, it won't work that way. MSBuild will only build one solution at a time. If you have dependencies from other solutions you will need to build those first then copy the resulting DLLs or EXEs into the right spot for the dependent solution. This can be done with the pre- and post-build actions in the project properties file.
Shortcuts usually aren't...

anil13
Posts: 2
Joined: Thu Dec 04, 2014 8:15 am

Re: How to build Ranorex projects from the command line

Post by anil13 » Wed May 06, 2015 6:37 am

When I build Ranorex projects via msbuild, I notice that the relative paths of the datasource files in the testsuite file(in bin\Debug) are not updated. e.g. ..\datasource remains as ..datasource(and not ..\..\..\datasource). Due to this, I get errors when I run the executable from Debug folder. How do I fix this?

Thanks

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

Re: How to build Ranorex projects from the command line

Post by odklizec » Thu May 07, 2015 7:40 am

Hi,

Check this post about Data source files organization and maintenance:
http://www.ranorex.com/forum/data-sourc ... ude#p31249
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

Groostav
Posts: 3
Joined: Fri Oct 09, 2015 6:15 am

Re: How to build Ranorex projects from the command line

Post by Groostav » Fri Nov 10, 2017 11:05 pm

Do the project files and solution files include a step to generate the C# source code?

What I would like to have is a repository of only .rxrec and .rxrep files, and have my build system re-generate the test-driver exes files from just those two file types. My understanding is that the ranorex studio will do this, first rebuilding the generated C# source code, then internally using MS build to create the exe, but only when run from a GUI mode. MSBuild alone does not appear to generate the C# source files.

Is this possible? Is there some kind of pre-processing action I can have MS build take to re-generate the C# source files on each build? Can ranorex studio itself simply be run from the command line to accomplish this?

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

Re: How to build Ranorex projects from the command line

Post by odklizec » Mon Nov 13, 2017 9:12 am

Hi,

I'm afraid, there is no way to re-build the cs files outside Ranorex and as far as I know, there is currently no option to re-build them using Ranorex Studio command line. Your best hope is to build all necessary files in Studio and store and distribute them via source control system (TFS, GIT, etc...).

If you wish, you can always create a user voice entry here (and hope for enough votes to get Ranorex devs attention :))...
https://uservoice.ranorex.com/forums/15 ... ve-ranorex
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: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: How to build Ranorex projects from the command line

Post by Stub » Mon Nov 20, 2017 2:43 pm

FWIW, like odklizec suggests, I store the Ranorex generated code in our source control system such that our automated build/test system can grab everything, build it all using MSBuild, then run the tests automagically. Works well. If I could automate generation of the Ranorex code files I'd remove these generated files from source control. So I'd vote for that at least!