Reprinted from: HTTP://HI.BAIDU.COM/GISINCE/ITEM/7F0439EE610C94255A2D64B4
Today writes the processing of the build event, as follows:
Down an example from the Web, the runtime prompts the error command "copy f:\ ... F:\ ... "has exited, the return value is 1; did not encounter before, from the online check, there is a netizen also has this problem, he is a program copy again, the program name into a" copy program name ", there is this problem, and the source program has no problems; so I put the program to the root of the F disk, run, The program is OK. Another analysis, is the program set up the "post-build event", made some copy operation, but do not know and the path has any problem, carefully see, our two program path has a space, is not the reason for the space, the path of the space is deleted, there is no problem.
It appears that the path in the command line that generated the event in VS does not support spaces, and should be noted later.
Copy/v "$ (TargetDir) $ (TargetName). dll" ". \.. \.. \.. \bin\ "
If Exist $ (TargetDir) $ (TargetName). PDB copy/v "$ (TargetDir) $ (TargetName). pdb" ". \.. \.. \.. \bin\ "
If Exist $ (TargetDir) $ (TargetName). XML copy/v "$ (TargetDir) $ (TargetName). xml" ": \.. \.. \.. \bin\ "
The above implementation copies the assembly files to the specified directory after the build is compiled, and here is a bin folder under the root directory
Copy the generated dll,lib to the specified directory, respectively:
Set my_target_path=. \.. \ Bin
copy/y $ (TargetPath)%my_target_path%
copy/y $ (TargetDir) $ (TargetName). pdb%my_target_path%
Set my_target_path=. \lib
copy/y $ (TargetDir) $ (TargetName). Lib%my_target_path%
In the VS Project properties Build Events tab, there is a post-build event command line, which you can enter here for example:
Copy $ (TargetDir) "C:\Program Files\mailsetup"
This will copy the generated files to C:\Program after the compilation is successful Files\mailsetup
Here are two points to note:
1. The target path should be enclosed in double quotation marks.
2, the use of the source of the macro is not required, such as can be written as $ (TargetDir) *.exe
3, if the project does not have any changes, "build" is not compiled, so when the run post-build event selected "Build Update project Output", will not be executed, but "regenerate" will be unconditional output, and trigger the event
VS Build Event