Build Action of files in folder - clarification please

Ranorex Studio, Spy, Recorder, and Driver.
loonquawl
Posts: 69
Joined: Wed Nov 22, 2017 10:08 am

Build Action of files in folder - clarification please

Post by loonquawl » Fri Dec 01, 2017 12:26 pm

Hi.
I have an executable(non-Ranorex, non-AUT) that is called by a UserCodeMethod.

Code: Select all

Process ykush = new Process();
ykush.StartInfo.FileName = "ykushcmd.exe";
ykush.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // only if UseShellExecute is false
ykush.Start();
It works fine as long as the corresponding .exe is placed directly in the project-view Project (properties: BuildAction none; Copy.. Always). What i'd like to do, as there are more .exe to follow, is to park the .exe in a folder in the project-view Project. As soon as i do that, the Project throws an error on execution, because the files are not found, because they do not get copied to bin/debug, despite their properties still being set as above.
I tried some BuildActions (EmbeddedResource, Resource) but to no avail.

Q1: Is there a documentation on what those build actions actually do?
Q2: What do i have to do to get a file from a folder inside a project to deploy directly into the bin/debug directory?
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Build Action of files in folder - clarification please

Post by odklizec » Fri Dec 01, 2017 1:02 pm

Hi,

All you have to do is to set the property (exe file included in project) "Copy to output directory" to "Always". It was already discussed here:
https://www.ranorex.com/forum/loading-i ... ml?#p33995
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Build Action of files in folder - clarification please

Post by Vaughan.Douglas » Fri Dec 01, 2017 1:06 pm

I have not tried this, but it's worth a shot. You should be able to create a folder then right click and add existing item. Navigate yourself to the location of your executable and select it (you might have to mess with the filter on the dialog). Once you've got it added check over the properties and see if there is something like "EmbeddedResource" as the build action. This should do it... maybe.

If that doesn't work, I'd start Googling. Ranorex is build on the ShareDevelop IDE, you may find these types of questions better answered there. Otherwise I'm sure someone else here is going to come along and correct me eventually.
Doug Vaughan

loonquawl
Posts: 69
Joined: Wed Nov 22, 2017 10:08 am

Re: Build Action of files in folder - clarification please

Post by loonquawl » Mon Dec 04, 2017 9:43 am

Thanks, odkllizec and Vaughan.Douglas,
but what you propose i already did. The problem is not that the file is not copied to the bin/debug folder, but that it is copied INSIDE the same folder structure that it is in in Solution-View. Yet the folders in solution-View are solely for organizing the View, not so the folder structure is replicated into bin/debug. Sorry if that was unclear from my initial post.

Meanwhile i found the answer on Stackoverflow:
If the .csproj file is altered to contain this:

Code: Select all

<ContentWithTargetPath Include="lib\some_file.dat">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <TargetPath>some_file.dat</TargetPath>
</ContentWithTargetPath>
It works the way i want it (If the copy always property is set, something like this is added to .csproj, you only need to change Content to ContentWithTargetPath, and have to add the targetpath tag.

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Build Action of files in folder - clarification please

Post by Vaughan.Douglas » Mon Dec 04, 2017 3:37 pm

loonquawl wrote:Thanks, odkllizec and Vaughan.Douglas,
but what you propose i already did. The problem is not that the file is not copied to the bin/debug folder, but that it is copied INSIDE the same folder structure that it is in in Solution-View. Yet the folders in solution-View are solely for organizing the View, not so the folder structure is replicated into bin/debug. Sorry if that was unclear from my initial post.

Meanwhile i found the answer on Stackoverflow:
If the .csproj file is altered to contain this:

Code: Select all

<ContentWithTargetPath Include="lib\some_file.dat">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <TargetPath>some_file.dat</TargetPath>
</ContentWithTargetPath>
It works the way i want it (If the copy always property is set, something like this is added to .csproj, you only need to change Content to ContentWithTargetPath, and have to add the targetpath tag.

This seems odd, I've never had any cause to do this beyond data sources. I just assumed it would work the same as it does in Visual Studio. This might be another one for UserVoice, although since it's probably related to the IDE it may not be doable for the Ranorex team.
Doug Vaughan