I have my chromedriver.exe in my local documents, working fine. But it's time to deploy to production. Somehow I need to bundle it with my software, and reference it locally.
How do I go about locally referencing my driver, and where should I put it?
Copy Chromedriver.exe into your project's solution / project folder. Add it to the project in visual studio. Right click the file and choose properties. Build Action should be set to 'Content'. That will mean when you build/deploy the bin folder will contain a copy of the chromedriver. When you reference the chromedriver.exe directly, you should look for it adjacent to the executable path of your program.
Good source on detecting location of current assembly/executable: How do I get the path of the assembly the code is in?
Related
I have developed several programs with selenium chromedriver. Getting the correct path to chromedriver on end users computer is sometimes an issue, how can I include the chromedriver exe in the program file, that it should automatically deploy and able to be used with messing around with the path to the driver file.
First you will need to add the exe to your project. Right click add existing item and navigate to the exe.
secondly you need right click on the exe in your project and get to the properties. set the exe to copy to output directory -> copy if newer or copy always.
this should get the file publishing with your installation. this all depends on how you are deploying, but with clickOnce or web deploy this will work. Ultimately setting the copy to output directory will get the exe into your bin folder on build.
If you need the location of the exe you should be able to use something like System.Reflection.Assembly.GetExecutingAssembly().Location to get the location of where the execution is taking place.
I'm new about code developing with Visual Studio 2010 and I would like to ask you a simple question about something after build a project.
I have a C# project and when I build It in Release mode some file are created and some of them copied from another in to \output\bin\Release\ folder. My question is that How can I manage that which created dll or created file will be in \output\bin\Release\ folder.
I tried to take a look at build properties of project but I could not find any option about it.
Thank you.
Actually I do not need this dll in my project output folder because I
add this dlls as a reference to my project
And this is exactly why this file appear in output folder.
There are several ways to "put" file in output folder. For normal files in the project you can set property Copy to Output Directory.
If we talking about dll's, (as mentioned Hans), there is Copy Local property for each assembly in References.
By default VS set this according to our GAC, so if you are using 3rd part assembly or from another project VS will set this property to True and file will be copied to output folder.
If you don't want to put this file in output folder, just set this property to False. But remember, at run time this assembly should exist.
For more information: How to: Set the Copy Local Property of a Reference
Another explanation: you just messed up with Output path in the project properties and two project has the same output folder. :)
I suggest that you ignore the extra files that are created. One way to do this is to configure the destination of these to a different location.
I use this:
property pages->General
- Output Directory = $(SolutionDir)..\link\
- Intermediate Directory = c:\temp\vc10\$(SolutionName)\$(Configuration)\
Use the same settings for debug and release.
I am trying to pull in a dependency, xulrunner to be exact. It is basically a folder of binaries and an executable called xulrunner.exe. The code initializes xulrunner for use by passing in the location of xulruner.exe to an api of another dll that my program uses.
How do I get visual studios to copy over the entire directory of xulrunner to the release folder on build so I can package xulrunner with my program and use a relative address when specifying the file path to xulrunner.exe.
You can add Post-build & Pre-build events to a project in visual studio. Go to the properties of the project and there will be a tab called 'Build Events'.
http://msdn.microsoft.com/en-us/library/42x5kfw4(v=vs.80).aspx
Should give you the necessary information.
Dragged the folder into the visual studios project.
Manually edited the folder entry in the csproject to do a recursive copy with "**"
Set the copy mode to Always
I'm setting up a TFS 2012 build agent and have run into a small problem with unit tests that reference external files. (Yes, yes, this is bad...no arguments there! I still have to get a build running) The tests are using the MSTest (VisualStudio.TestTools.UnitTesting) framework.
Currently, there is a Resources folder under the solution root, and all the tests (which are unfortunately at varying depths in subdirectories) load files with some level of relative paths (..\\..\\..\\Resources\\resource.txt).
TFS, as you know, copies all output to a bin folder that is at the same level as src, which has the required Resources folder. There is no way to copy this folder high up enough in the directory structure so the tests pass for the build agent.
I am hoping that either of these questions can give me a stop-gap solution to this problem:
Is there any environment variable (or something similar) that I could use to detect that the unit test is being run through a TFS build agent and change the path to the resource file in code accordingly?
Is there a simple way to tell TFS to output files into the bin folder with the same hierarchy as they would have normally been if built in Visual Studio? (The reason I say simple is because I've found some rather long build modifications that could probably handle this)
Option1: Yes, you can copy a folder and it's contents to the \bin\Debug folder:
Add a folder to your test project
Add your files in that folder and in Visual Studio set each file property "Copy to Output Directory" : "Copy Always"
Option 2: You can also put your file into a resource file
Option 3: or declare the file it in your test using the attribute:
[TestMethod]
[DeploymentItem("mytestdata.xml")]
EDIT: This is a VS2008 app written in C#.
So I have a folder in my solution called
_lib/
It's where I keep my DLLs so that when I reference them, they get built into the bin/ folder.
Now I have a new item in my solution. It's a DLL but shouldn't be reference (it's required for a 3rd party app). So on build I want this to be copied from _lib/ to bin/ but NOT referenced in the project.
I've included the _lib/ folder in my app, and for the properties of that DLL I selected always copy. This ALMOST worked, it copies the file with the folder, so my structure looks like:
/bin/_lib/thedll.dll
Instead of
/bin/thedll.dll
Any ideas?
Try following these steps in Visual Studio:
Expand the project tree concerned
Double click the Properties element
In the opened window click the Build Events tab
In the Post-build event command line text area place this:
xcopy "$(ProjectDir)_lib\file.ext" "$(ProjectDir)bin\$(ConfigurationName)"
Open the expected output folder alongside Visual Studio
Hit CTRL+Shift+B to make sure everything is saved and build
Feel the sense of achievement well up inside you as your file appears
:)
Oh, and you can now set Copy to output directory to Do not copy.