Ref:http://blog.csdn.net/teng_ontheway/article/details/8307410
Ref: http://blog.csdn.net/sodickbird/article/details/4826068
需求:
需求:可能我们需要给美工发布一个版本,那就需要*.exe, *.dll 和资源都放在一个文件夹下,然后同步给美工
问题:生成工程的时候.exe生成目录可能和资源目录不一致,总不能每编译一次都手动的把生成的.exe 和 dll拷贝到资源目录下吧
解决办法:用visual studio自带的生成后批处理命令
visual studio->右键工程->properties->Build Events->Post-Build Event->Command Line下
xcopy $(OutDir)$(TargetFileName) $(ProjectDir)..\Resources\ /Y
这个命令式功能是将生成目录下的exe文件拷贝到工程目录上一级目录下的Resources文件夹下
注意点:
1.$(OutDir)等宏路径中已经附带了‘\‘
2.生成后事件xcopy其实就是运行一个控制台命令,所以命令不支持‘/‘
像之前写的一个错误命令
xcopy $(OutDir)$(TargetFileName) $(ProjectDir)../Resources\ /Y
运行会提示错误
3.“/Y"是参数,表示有相同文件存在则替换
当然也可以拷贝整个文件夹
xcopy "$(ProjectDir)controls" "$(TargetDir)..\app1\controls" /y /i /e /exclude:CodeFilesToExclude.txt
具体参数就要参考到CMD控制台下查看xcopy的具体功能了...
Bin Folders
Each project should write their output to a Bin folder under each of the Dev Folders. The Bin should NOT be checked into TFS, but should be created via a post-build event or by changing the project’s output path.
If post-build events are used, the following is a sample which assumes the solution in in the root directory:
@echo if not exist "$(SolutionDir)Cloud\bin\" (mkdir "$(SolutionDir)Cloud\bin\")
if not exist "$(SolutionDir)Cloud\bin\" (mkdir
"$(SolutionDir)Cloud\bin\")
@echo copy /Y "$(TargetDir)$(TargetName).*"
"$(SolutionDir)Cloud\bin\"
copy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)Cloud\bin\"
Note:
Make sure you echo statements before
you execute them. This can help in debugging post-build failures in build log
files.