References to Ranorex 8.x in Visual Studio

Class library usage, coding and language questions.
toms
Posts: 2
Joined: Wed Aug 01, 2018 1:51 pm

References to Ranorex 8.x in Visual Studio

Post by toms » Wed Aug 01, 2018 2:03 pm

Hi,
I'm currently updating our Visual Studio test solution, which heavily uses the Ranorex API, to version 8.2 (from 7.2).

While doing this, I noticed that I can't select the Ranorex assemblies directly under the "Extensions" tab in the "Add Reference..." dialog anymore, but have to add the assemblies by their absolute path (as described here: https://www.ranorex.com/help/latest/int ... tegration/).
This is probably caused by the fact that Ranorex is not registered in the registry anymore. Ranorex 7.2 was registered in the registry key

Code: Select all

HKLM\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx
during the setup.

My question now is: is this intended, or a setup bug? As we use multiple test projects inside our solution, adding all Ranorex assemblies to them is both kind of annoying and takes a lot of time. I was able to reproduce this on two different machines.

Thanks in advance!
Tom

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: References to Ranorex 8.x in Visual Studio

Post by asdf » Thu Aug 02, 2018 12:39 pm

Hi Tom,

I'm pretty sure that this issue is caused by the "GAC less" feature of Ranorex. This feature makes it a lot easier to execute your tests without having Ranorex installed. I would suggest to copy the file "Ranorex.Core.Resolver.dll" directly to the exe file of your test. This file is located under "C:\Program Files (x86)\Ranorex 8.2\Bin\Ranorex.Core.Resolver.dll".
If this file is directly beside the test exe, it will search for the Ranorex Dll's in the installation directory.

I hope that helps.
asdf

ahoisl
Certified Professional
Certified Professional
Posts: 192
Joined: Fri Sep 07, 2007 8:16 am

Re: References to Ranorex 8.x in Visual Studio

Post by ahoisl » Thu Aug 02, 2018 9:01 pm

toms wrote:
Wed Aug 01, 2018 2:03 pm
My question now is: is this intended, or a setup bug? As we use multiple test projects inside our solution, adding all Ranorex assemblies to them is both kind of annoying and takes a lot of time. I was able to reproduce this on two different machines.
This is indeed intended, yes, because Ranorex assemblies are no longer installed in the GAC.

However, there should not be a reason to add all hintpaths or add the references anew if you use the Ranorex.MSBuild.Targets. You can either try to get it to work by copying the relevant lines from a new Ranorex project, or just open the solution/project once with Ranorex Studio, which should do all necessary conversion for you.

Regards,
Alex
Ranorex Team

toms
Posts: 2
Joined: Wed Aug 01, 2018 1:51 pm

Re: References to Ranorex 8.x in Visual Studio

Post by toms » Tue Aug 07, 2018 1:21 pm

Hi,
thanks to both of you for your help. A combination of both approaches worked in our case; adding the build targets and a reference to Ranorex.Core.Resolver.dll did the trick. Updating this to new Ranorex versions should also be easy, as we can just use a script to replace the content of <RanorexVersion>.

Just in case anyone else encounters this problem, this is our solution (mostly copied from a project created with Ranorex Studio):
  1. Add the following code to the first <PropertyGroup> in the .csproj file, e.g. beneath <AssemblyName>:
    <RanorexVersion>8.2</RanorexVersion>
    <RanorexTargetsPath>$(MSBuildProgramFiles32)\MSBuild\Ranorex$(RanorexVersion)\Ranorex.MSBuild.Targets</RanorexTargetsPath>
    
  2. Replace the Ranorex references under <ItemGroup> with the following lines:
    <Reference Include="Ranorex.Core">
      <Private>False</Private>
    </Reference>
    <Reference Include="Ranorex.Bootstrapper">
      <Private>False</Private>
    </Reference>
    <Reference Include="Ranorex.Core.Resolver">
      <Private>True</Private>
    </Reference>
    
  3. Lastly, add the Ranorex build target at the very end of the file, just before the closing </Project> tag;
    <Import Project="$(RanorexTargetsPath)" Condition="Exists('$(RanorexTargetsPath)')" />
    
Best,
Tom
Last edited by toms on Tue Aug 14, 2018 10:32 am, edited 1 time in total.

User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: References to Ranorex 8.x in Visual Studio

Post by Aracknid » Tue Aug 07, 2018 4:15 pm

Thanks for posting your solution with steps. I had asked the same question and was given the same answer but didn't really get it and had found another way around it (but not as good)...

Does this need to be done to ALL project files, or can it be done to the first project file that is compiled in the chain of dependencies?

For example, I have 1 DLL that contains all my framework and is compiled first and is required by every other file built afterwards, and then 1 exe for each script, so I have well over 1500 exe's and they all have an associated project file. Most of the references to ranorex files are contained within the DLL, but there are a few EXE files that occasionally have a reference to a ranorex file.

If I have to update all the EXE's project files, can anyone recommend a fast way of doing this?

Thanks,

Aracknid.

User avatar
RobinHood42
Posts: 324
Joined: Fri Jan 09, 2015 3:24 pm

Re: References to Ranorex 8.x in Visual Studio

Post by RobinHood42 » Thu Aug 16, 2018 2:18 pm

Hi,

As Alex wrote, the DLL's are no longer available in the GAC, I assume adding the Resolver to the .csproj file is necessary for all exe files.
In order to speed this process up, you can write a script which adds the necessary lines to the .cspoj files.

Here is an example how you can do this.
https://www.roelvanlisdonk.nl/2010/09/2 ... rs-with-c/

Cheers,
Robin