How to change value of <Reference> persistent inside .rxtst

Ranorex Spy, Recorder, and Studio.
PatrickGruber
Posts: 5
Joined: Fri Nov 18, 2016 3:02 pm

How to change value of <Reference> persistent inside .rxtst

Post by PatrickGruber » Tue Nov 07, 2017 4:05 pm

Hi Ranorex-Team,
I got "ProjectA.csproj" with a reference "Dependency.dll", since I have on production system that reference, I set "Copy to ouput" false.
When I add the reference via Ranorex, then it will write inside the csproj file:

Code: Select all

<Reference Include="Dependency">
  <HintPath>Resources\References\Dependency.dll</HintPath>
  <Private>False</Private>
</Reference>
Also in the .rxtst it will write:

Code: Select all

<reference>
	..\..\Resources\References\Dependency.dll
</reference>
I found out Ranorex loads the "Dependency.dll" from the path provided inside the .rxtst
When I start my "ProjectA.exe" (build with ranorex) on my development machine, where the "Dependency.dll" is also installed in some folder (what the application loads at a later point), THEN, Ranorex loads it from the path provided in the .rxtst file, because if I delete inside my .rxtst (located in the bin\Release) the paths:
New .rxtst file

Code: Select all

<reference>
	Dependency.dll
</reference>
Then, I see with ProcExp that the assembly from "Resources\References\" will NOT be loaded anymore.

Unfortunately, if I want in my real .rxtst (and not in the bin\Release) to change theses values permanently, I tried again to change them via Notepad, but they are ovverriden when someone opens with Ranorex the project with the "HintPath" from the .csproj.

How could I make the paths of my references inside the .rxtst persistent?

Project Structure relative from .csproj:
OUTPUT: bin\Release
REFERENCES: Resources\References


Thanks,
Patrick
Last edited by PatrickGruber on Fri Nov 10, 2017 3:50 pm, edited 1 time in total.

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to change value of <Reference> persistent inside a .rxts

Post by McTurtle » Thu Nov 09, 2017 4:23 pm

Hello Patrick,

I am not sure that this is possible. On your development system you should set the actual path to where the dll is located on your development system. If you are not going to copy the dll over to the production system, then you should use the app.config to set the location of the dll for the production system.

You can read a detailed step-by-step guide on how to set the location of assemblies during runtime under this link: How to load an assembly at runtime that is located in a folder that is not the bin folder of the application

Does this link help?

Regards,
McTurtle

PatrickGruber
Posts: 5
Joined: Fri Nov 18, 2016 3:02 pm

Re: How to change value of <Reference> persistent inside a .rxts

Post by PatrickGruber » Fri Nov 10, 2017 3:49 pm

Hi McTurtle,
thanks for the quick answer. :wink:

I can not reference the Assembly from the "Installation directory" because then it would not build anymore on a clean machine (for instance, Build server).

I have no trouble to load and find the assembly at runtime, this is currently implemented with an Assembly Resolver. The assemblies are loaded before somehow, I think Ranorex loads instantly, after launching the .exe (built with Ranorex), the mentioned <Reference> inside the .rxtst from the provided path. :?

Thanks,
Patrick

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to change value of <Reference> persistent inside .rxtst

Post by McTurtle » Mon Nov 13, 2017 11:19 am

Hello PatrickGruber,

What about adding the assemblies to the GAC?

Regards,
McTurtle

PatrickGruber
Posts: 5
Joined: Fri Nov 18, 2016 3:02 pm

Re: How to change value of <Reference> persistent inside .rxtst

Post by PatrickGruber » Fri Nov 17, 2017 7:34 am

Hi McTurtle,
thanks for your message and your help!

That would not solve my issue: Like I said "{..} then it would not build anymore on a clean machine (for instance, Build server)."

Regards,
Patrick

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

Re: How to change value of <Reference> persistent inside .rxtst

Post by krstcs » Fri Nov 17, 2017 2:24 pm

Can you just add the necessary libraries to the project as "Existing files" and set them to copy to the output directory on build? Then it won't matter if the build system has the files in the GAC or if they are on the test system, they would already be part of the project and would always be with the project because they should be checked in to your version control system with the Ranorex solution. .NET executables always check the local directory first when looking for library references, so your local copy would take priority over the GAC/system copy.

Your other option is to find or create a NuGet package for the necessary libraries and fetch those packages before the build through NuGet.
Shortcuts usually aren't...