Page 1 of 1

References to Ranorex 8.x in Visual Studio

Posted: Wed Aug 01, 2018 2:03 pm
by toms
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

Re: References to Ranorex 8.x in Visual Studio

Posted: Thu Aug 02, 2018 12:39 pm
by asdf
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

Re: References to Ranorex 8.x in Visual Studio

Posted: Thu Aug 02, 2018 9:01 pm
by ahoisl
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

Re: References to Ranorex 8.x in Visual Studio

Posted: Tue Aug 07, 2018 1:21 pm
by toms
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

Re: References to Ranorex 8.x in Visual Studio

Posted: Tue Aug 07, 2018 4:15 pm
by Aracknid
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.

Re: References to Ranorex 8.x in Visual Studio

Posted: Thu Aug 16, 2018 2:18 pm
by RobinHood42
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