Copying a project from one solution to another?

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Copying a project from one solution to another?

Post by Fergal » Thu May 05, 2016 3:35 pm

[Ranorex 5.4.6, Windows 7]

Solution A
- Project One

Solution B
- Project Two

I have copied Project Two into Solution A, using Solution A Context Menu > Add > Existing Project.

In Ranorex, Project Two now appears in Solution A and is running fine from there. However, when I open Solution A in Windows Explorer, it does not contain Project Two.

Is there a way to copy the project so that it is actually also included in Solution A?

Thanks!

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

Re: Copying a project from one solution to another?

Post by krstcs » Thu May 05, 2016 4:59 pm

I would strongly caution against doing this as Ranorex uses GUIDs behind the scenes to uniquely identify objects (modules, test case, variables, data sources, etc.). If you copy from one solution to another, there is no guarantee that you won't duplicate a GUID that is already being used, or that Ranorex will recognize the new GUIDs.


Having said, that, the best thing to do is to copy the required project into the new solution's directory first, and then add the copy to the new solution so your relative paths match up. To do this now, you probably need to delete the existing project from the solution you want to copy it to, and then copy the folder and re-add it.
Shortcuts usually aren't...

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Copying a project from one solution to another?

Post by Fergal » Fri May 06, 2016 12:17 pm

Thanks for the helpful advice and suggestions krstcs. I am taking your advice and will not import the project. Instead I am adding the individual modules to the merged solution and then recreating the TCs using those modules. That has resulted in the issue below:

Original "CodeModules" Folder
- Original Code Module 1
- Original Code Module 2

After adding new code modules the folder now looks like this:

Merged "CodeModules" Folder
- Original Code Module 1
- Original Code Module 2
- Newly Added Code Module A
- Newly Added Code Module B

When editing "Newly Added Code Module A" if I type "CodeModules." it gives me the option to "see" / access "Newly Added Code Module B". However, it is not "seeing" or allowing me to access "Original Code Module 1" or "Original Code Module 2". In other words, the newly added modules can see each other, but not the original modules. The reverse is also true, when editing one of the original modules I can access the other original modules, but not the newly added modules. How can I fix that?
krstcs wrote:...If you copy from one solution to another, there is no guarantee that you won't duplicate a GUID...
Would it be true to say that although there is no guarantee that a GUID would be duplicated, it is however, extremely unlikely that it would ever happen? Perhaps my code module issue above is related to the GUIDs?

Thanks again!

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

Re: Copying a project from one solution to another?

Post by krstcs » Fri May 06, 2016 3:11 pm

Your copied modules probably do not have a reference to the existing modules and vice-versa. If you use a text editor (try Notepad++, it's the best Windows text editor I've every seen!) and open the RXREC files, you should see that they have references to the other modules at the top of the XML structure somewhere. You MIGHT be able to copy each individual reference into all the other files and get it working.


However, as I said, it isn't recommended to copy ANYTHING from one solution to another due to this and the GUID issues. My hope is that Ranorex will make an import function that will do this for you by recreating the GUIDs and references when you import external objects at some point, but that is probably a very low priority for them.


edit: spelling...
Shortcuts usually aren't...

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Copying a project from one solution to another?

Post by Fergal » Tue May 10, 2016 1:13 pm

Thanks for your help and advice krstcs. What I've done is recreated the imported code modules, by adding new code modules and copying and pasting some of the code from the old modules into the new modules. The new code modules obviously needed some refactoring, but overall the process seems to have worked pretty well.

Thanks again!

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

Re: Copying a project from one solution to another?

Post by krstcs » Tue May 10, 2016 2:35 pm

You're welcome!

I usually do the same thing when merging projects/solutions, I just copy the code and recreate the rest.


Another tip: If you find yourself copying code to multiple projects, that is probably a good candidate for a library class. That way you only have one place to make changes, if needed.
Shortcuts usually aren't...

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Copying a project from one solution to another?

Post by Fergal » Wed May 11, 2016 9:34 am

krstcs wrote:...Another tip: If you find yourself copying code to multiple projects, that is probably a good candidate for a library class. That way you only have one place to make changes, if needed.
Thanks I do a little of that, but it is an area that I will be learning more about, to help make our solutions more efficient.