Page 1 of 1

Build Action of files in folder - clarification please

Posted: Fri Dec 01, 2017 12:26 pm
by loonquawl
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?

Re: Build Action of files in folder - clarification please

Posted: Fri Dec 01, 2017 1:02 pm
by odklizec
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?

Re: Build Action of files in folder - clarification please

Posted: Fri Dec 01, 2017 1:06 pm
by Vaughan.Douglas
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.

Re: Build Action of files in folder - clarification please

Posted: Mon Dec 04, 2017 9:43 am
by loonquawl
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.

Re: Build Action of files in folder - clarification please

Posted: Mon Dec 04, 2017 3:37 pm
by Vaughan.Douglas
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.