Widnows bat 编译VS项目
来源:互联网 发布:少女漫画推荐 知乎 编辑:程序博客网 时间:2024/06/05 10:10
因为项目需要,有时候直接采用bat文件编译整个项目,有很好的工具可用,就是devenv.
///设置要调用的devenv路径
set _devenv="%VS110COMNTOOLS%..\..\Common7\IDE\devenv.com"
///设置log文件名和路径
set _log="%~dp0compileResults.log"
///当前路径--%~dp0表示当前的bat文件所在的路径,此处是为了获取PARENT路径
set Directory= %~dp0
set Directory=%Directory:~0,-1%
for %%d in (%Directory%) do set ParentDirectory=%%~dpd
echo [�TE% %Time%] Start compile sequence >%_log%
::echo Used compile configuration is %buildAnyCPU% >>%_log%
set _solution_files="%ParentDirectory%test.sln"
echo _solution_files
set _project_file="%~dp0test.vcxproj"
rem Start Debug Mode compile************************************************
///设置编译参数,相当于项目中的宏定义,从而实现根据不同的宏编译出不同的输出文件
////此处类似于宏定义 #define PREFEFINETEST
///cl的用法参考msdn
set CL=/DPREDEFINETEST
echo %CL%
del %ParentDirectory�bug\*.*
%_devenv% %_solution_files% /build "Debug|Win32" /project %_project_file% /Out %_log%
if not %errorlevel% == 0 echo %_project_file% failed! Error: %errorlevel% >>%_log%
if %errorlevel% == 0 echo %_project_file% compiled successful >>%_log%
rem If compile failed stop processing:
::if not %errorlevel% == 0 pause
::following code just get the parent path,to be changed
echo [�TE% %Time%] Finished Debug compile sequence >>%_log%
///重新命名
ren %ParentDirectory�bug\test.dll testsuccess.dll
ren %ParentDirectory�bug\test.lib testsuccess.lib
ren %ParentDirectory�bug\test.exp testsuccess.exp
ren %ParentDirectory�bug\test.ilk testsuccess.ilk
ren %ParentDirectory�bug\test.pdb testsuccess.pdb
set CL=
echo %CL%
%_devenv% %_solution_files% /build "Debug|Win32" /project %_project_file% /Out %_log%
if not %errorlevel% == 0 echo %_project_file% failed! Error: %errorlevel% >>%_log%
if %errorlevel% == 0 echo %_project_file% compiled successful >>%_log%
rem If compile failed stop processing:
::if not %errorlevel% == 0 pause
::following code just get the parent path,to be changed
echo [�TE% %Time%] Finished Debug compile sequence >>%_log%
pause
链接:
获取parent 路径:
http://wiert.me/2011/08/09/batch-files-getting-directory-and-parent-directory/
http://jonausten.info/2011/11/02/windows-batch-file-find-parent-folder-name/
关于devenv的使用:
http://blog.sina.com.cn/s/blog_6234a2f00100fku8.html
CL的用法:
http://msdn.microsoft.com/zh-cn/library/kezkeayy.aspx
注意: 设置完之后如果需要取消 则直接
set CL=
即不赋值即可.
http://msdn.microsoft.com/en-us/library/a4sf02ac.aspx
///设置要调用的devenv路径
set _devenv="%VS110COMNTOOLS%..\..\Common7\IDE\devenv.com"
///设置log文件名和路径
set _log="%~dp0compileResults.log"
///当前路径--%~dp0表示当前的bat文件所在的路径,此处是为了获取PARENT路径
set Directory= %~dp0
set Directory=%Directory:~0,-1%
for %%d in (%Directory%) do set ParentDirectory=%%~dpd
echo [�TE% %Time%] Start compile sequence >%_log%
::echo Used compile configuration is %buildAnyCPU% >>%_log%
set _solution_files="%ParentDirectory%test.sln"
echo _solution_files
set _project_file="%~dp0test.vcxproj"
rem Start Debug Mode compile************************************************
///设置编译参数,相当于项目中的宏定义,从而实现根据不同的宏编译出不同的输出文件
////此处类似于宏定义 #define PREFEFINETEST
///cl的用法参考msdn
set CL=/DPREDEFINETEST
echo %CL%
del %ParentDirectory�bug\*.*
%_devenv% %_solution_files% /build "Debug|Win32" /project %_project_file% /Out %_log%
if not %errorlevel% == 0 echo %_project_file% failed! Error: %errorlevel% >>%_log%
if %errorlevel% == 0 echo %_project_file% compiled successful >>%_log%
rem If compile failed stop processing:
::if not %errorlevel% == 0 pause
::following code just get the parent path,to be changed
echo [�TE% %Time%] Finished Debug compile sequence >>%_log%
///重新命名
ren %ParentDirectory�bug\test.dll testsuccess.dll
ren %ParentDirectory�bug\test.lib testsuccess.lib
ren %ParentDirectory�bug\test.exp testsuccess.exp
ren %ParentDirectory�bug\test.ilk testsuccess.ilk
ren %ParentDirectory�bug\test.pdb testsuccess.pdb
set CL=
echo %CL%
%_devenv% %_solution_files% /build "Debug|Win32" /project %_project_file% /Out %_log%
if not %errorlevel% == 0 echo %_project_file% failed! Error: %errorlevel% >>%_log%
if %errorlevel% == 0 echo %_project_file% compiled successful >>%_log%
rem If compile failed stop processing:
::if not %errorlevel% == 0 pause
::following code just get the parent path,to be changed
echo [�TE% %Time%] Finished Debug compile sequence >>%_log%
pause
链接:
获取parent 路径:
http://wiert.me/2011/08/09/batch-files-getting-directory-and-parent-directory/
http://jonausten.info/2011/11/02/windows-batch-file-find-parent-folder-name/
关于devenv的使用:
http://blog.sina.com.cn/s/blog_6234a2f00100fku8.html
CL的用法:
http://msdn.microsoft.com/zh-cn/library/kezkeayy.aspx
注意: 设置完之后如果需要取消 则直接
set CL=
即不赋值即可.
0 0
- Widnows bat 编译VS项目
- 使用bat脚本编译VS工程
- bat命令编译vc和vs工程
- 编译C51项目的bat脚本
- vs编译项目更新dll
- [BAT]VS自动取TFS代码,自动编译并打包
- VS中的项目使用bat脚本进行构建
- Jenkins:VS项目的自动化编译
- Jenkins:VS项目的自动化编译
- VS NET代码实现编译构建项目
- 不打开VS IDE 编译项目工程
- cmake编译OpenCV生成VS项目
- 并行编译加快VS C++项目的编译速度
- 并行编译加快 VS C++ 项目的编译速度
- 并行编译加快 VS C++ 项目的编译速度
- 并行编译加快 VS C++ 项目的编译速度
- 编译选项bat
- .BAT简化编译过程
- 手工转换中缀式与前、后缀式(转)
- Linux学习--进程概念
- 浅析 Get 和 Post 的区别
- QWidget,QMainWindow和QDialog的区别
- 四、原型模式Prototype(创建型)
- Widnows bat 编译VS项目
- oracle11g ORA-01017:invalid username/password:logon denied
- 一个经典的问题的思考: strcpy覆盖内存
- linphone-PresenceService.java文件分析
- K-Means聚类算法java实现
- Swift与Objective-C的兼容“黑魔法”:@objc和Dynamic
- 6. ZigZag Conversion
- 版本更新、下载、安装
- xlistview