Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure post-build events for setup/deployment projects in Visual Studio

My solution has two projects. One is my actual project and another one is setup project.

My actual project has one report folder where I store my all ssrs report. I have one folder in the setup project called "SSRS_Repor". Now I want that when I will do a batch build then setup for my project regenerate, and then I want to copy all files from the report folder of my actual project to SSRS_Repor in my setup project.

If I can do this kind of automation of copying files from one location to another folder of my setup project, then I could be get rid of manual copying of rdls files. I heard this is possible by setup/deployment projects. I searched Google for this for details step-by-step instruction, but I didn't get any good links. So please guide me how can I do it.

I posted it to another forum too, and some one told me below this:

Open or create a setup/deployment project in Visual Studio 2005
Press F4 to display the Properties window
Click on the name of your setup/deployment project in the Solution Explorer
Click on the PostBuildEvent item in the Properties window to cause a button labeled "..." to appear
Click on the "..." button to display the Post-build Event Command Line dialog
Add a command line of your choice in the Post-build event command line text box
Build your project in Visual Studio and verify that the post-build event is executed after the main MSI build

So it is OK, but what do I need to write for copying files from one location to another location? That is not clear to me. So now this is most important for me what to write for copying file during setup generation.

I got another clue like below one. A script for setup Pre/Post Build Event, but not aware properly. I got a sample like

copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)lib\$(ProjectName).dll"

The above statement or line is not clear to me. What do I need to write in my case? I need a step-by-step guide.

Here is the screenshot of my project structure

Enter image description here

like image 901
Thomas Avatar asked Oct 04 '12 12:10

Thomas


People also ask

How to use post build event in Visual Studio?

In the Post-build event command line box, specify the syntax of the build event. Add a call statement before all post-build commands that run . bat files. For example, call C:\MyFile.

How do I run a batch file in post build event?

If you go to the Properties page for your project, you should select the Build Events tab. You can type in the call to your batch file in the Post-build event command line text box. If you want to refer to the batch file using the paths included in the project or solution, you can click on the Edit Post-Build...

How do I open a build event in Visual Studio?

Go to Solution Explorer and right-click on the project then select Properties then go to the Build Events tab. If you click on the Edit Pre/Post build event command line button the following dialog will open.


1 Answers

To answer your question simply:

The commands that you input in the build events (be it pre or post) are the same as you would enter in a command line box.

In your example:

copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)lib\$(ProjectName).dll"

copy is the actual DOS copy command.

/Y is a regular switch that prevents confirmation prompts.

"$(TargetDir)$(ProjectName).dll" is the source file to copy.

"$(SolutionDir)lib\$(ProjectName).dll" is the destination where to copy the file.

You can refer here to have additional information on batch file commands: Batch command list

The $({Identifier}) are macros you can use in Visual Studio Pre/Post Build event designer.

You can refer to the MSDN online help for more details on macros: MSDN Macros List

The line provided to you would not do what you want. It's usually used to copy DLL files to a library folder used by some other projects or solution.

The solution you found to create a new build event is correct.

All you have left to do is write down the command that will actually copy the files.

It would look something like this:

XCOPY "$(SolutionDir)TestProject\Reports\*.*" "$(SolutionDir)TestSetup1\SSRS_Repor" /Q /E /I

/Q : Quiet | Don't display files being copied

/E : Recursive (copy subfolder structure and files)

/I : Consider that destination is a folder if it does not already exist (will create a new folder if required)

like image 106
Yan Brunet Avatar answered Oct 03 '22 20:10

Yan Brunet