Page 1 of 1

Adding code modules programmatically to Ranorex

Posted: Fri Nov 15, 2019 9:09 pm
by Lex
Hello,

Lately I’ve been working on generating simple code modules which do simple things for our automations. I have no issues adding them to the Visual Studio solution but once I try to run them in ranorex I get the Module Could Not Be Found error. I was wondering if anyone has a potential fix for this.

The only potential fix we have found it adding them through the editor but Ranorex doesn’t have an add folder which adds everything in it or a copy/add all button, it makes it so we have to spam a button which kinda defeats the point of doing this programmatically.

If anyone has any information that could help me out it would be greatly appreciated.

Thank you,
Lex

Edit: I’ve found the answer for anyone else who runs into this problem in the future. Surprisingly the missing module has nothing to do with ranorex. In the .csproj file when you use Microsoft.Build.Evaluation.Project.AddFile it doesn’t automatically tag your objects to be compiled. I’ve written something that simply edits the the .csproj file now.

Re: Adding code modules programmatically to Ranorex

Posted: Mon Nov 18, 2019 9:59 am
by odklizec
Hi,

I'm afraid, there is no (publicly available) way to achieve what you want via code. I would suggest to create a feature request here:
https://uservoice.ranorex.com/forums/15 ... ve-ranorex

Re: Adding code modules programmatically to Ranorex

Posted: Fri Dec 27, 2019 8:07 pm
by cparsons
Lex wrote:
Fri Nov 15, 2019 9:09 pm

Edit: I’ve found the answer for anyone else who runs into this problem in the future. Surprisingly the missing module has nothing to do with ranorex. In the .csproj file when you use Microsoft.Build.Evaluation.Project.AddFile it doesn’t automatically tag your objects to be compiled. I’ve written something that simply edits the the .csproj file now.
Hey, Lex. How exactly did you solve the problem with the .csproj file? We are looking into this as well and have had some issues with this as well. What was the code that you wrote?

Thanks,
Cole

Re: Adding code modules programmatically to Ranorex

Posted: Tue Feb 11, 2020 6:24 pm
by Lex
Hey Cole,

I haven’t been using the forums much in the past month since you replied so I apologize for the delay.

I hope you’ve figured it out, but I’ll still inform you of my solution.

Using the XmlDocument class in the Xml c# library, I simply added new nodes to the ItemGroup node which contained Compile nodes. From there you generate a new node with the name Compile, give it an attribute with the name Include and the path as a value, then give this node a child named ID. The ID child’s inner text is simply a newly generated GUID which you get from the system library.