November 29, 2019

Using Post Build events to copy files in Visual Studio

  November 29, 2019
The files we may want to use after a build may vary on our framework structure.
What if we have test and base framework as two separate projects in a solution.

On above condition  we have to do two things to make our solution work.
  1. Refer our base framework to the test framework.


Then select the base framework as a reference from reference manager.


2. As a next step we need to copy all the files created in Base project output to output folder of our test project.

On considering the selenium testing, files like chromedriver.exe, selenium standalone server, any excel files used to data  drive etc are kept in base project only.

If we have to run the test , we have to copy these files to output folder of the test project.(including .dll of test project)

So an easy method to copy all the files in Base project/Debug to Test project/Debug is to set post build events in out test project. 
This event will trigger once the solution build is completed.

For this we have to set the build order first, so that the base project builds first and then the test project.

To set this , Right click on the solution and select build order.


The select the base project as build dependency of test project.



As next step we have to write a post build even in test project. For doing this go to properties section of test project and select build events->Post build even command line and type in below command.

xcopy "$(SolutionDir)<BaseProjectName>\bin" "$(ProjectDir)bin" /E /I /Y /D

By entering this as post build event , we are copying all the files created in bin folder of base project to the test project.


logoblog

Thanks for reading Using Post Build events to copy files in Visual Studio

Previous
« Prev Post

No comments:

Post a Comment

How to send email from current Outlook instance using Java + VBScript

If we are using .Net, we can easily access outlook and send emails using its own libraries. But what if we are using Java? Here we can seek ...