首页 > 其他 > 详细

post- build event

时间:2015-04-21 20:23:57      阅读:133      评论:0      收藏:0      [点我收藏+]

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.

post- build event

原文:http://www.cnblogs.com/purple1/p/4444938.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!