How to include non C# files when running to a remote agent

Best practices, code snippets for common functionality, examples, and guidelines.
Bumler
Posts: 3
Joined: Mon Nov 20, 2017 8:16 pm

How to include non C# files when running to a remote agent

Post by Bumler » Tue Dec 12, 2017 8:24 pm

I have an .xlsx file stored in my project and need to open and read it in a C# class in order to properly set my environment when running a test both locally and remotley. The excel file contains a list of commands that my class needs to read through and run on a host.

I've included the .xlsx file in my project folder and when I run it locally. I am able to refer to it as 'fileName.xlsx' and it finds and accesses it as expected. Unfortunately, when I run the same project via remote agent it is unable to find the file. Ideally I'd like a solution where I can pass in the file as a file location like I'm currently doing now rather than trying to load it in as a datasource.

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

Re: How to include non C# files when running to a remote agent

Post by McTurtle » Wed Dec 13, 2017 2:48 pm

Hello Bumler ,

Have you added it to your project as an existing item:
Item.png
After adding it, it should be visible in the project view:
TestWorkbook.png
Then you must open the properties of the excel file by right clicking on it in the project view and navigating to "Properties".
Make sure to set the "Copy to output directory" option to "Always":
output.png
You should now be able to use only the file name as the path value of any method you are using in your code since your methods will access directly the file from the output directory.

Regards,
McTurtle
You do not have the required permissions to view the files attached to this post.