打包脚本的流程和自动打包基本相同:
1. 编译软件
2. 拷贝需要的内容
3. 代码签名
4. 打包成安装文件
5. 再次签名,并将安装文件名称改成需要的格式
------------------------------------------------------------------
编译软件需要初始化vs的运行环境,如
call "D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/vcvars32.bat"
然后开编译。
编译完成,拷贝文件,使用signtool对软件进行签名,
signtool sign /f codesign.cer ../bin/app/Joywok.exe
最后将其修改为需要的命名风格,这里使用了 git rev-list HEAD --count 来获取git的提交次数作为build version
rem 修改软件名称for /f "delims=" %%i in ('git rev-list HEAD --count') do (set "buildversion=%%i")echo %buildversion%cd setupset year=%date:~0,4%set month=%date:~5,2%set day=%date:~8,2%set ymd=%year%%month%%day%-b%buildversion%ren setup.exe joywok-aws-setup-%ymd%.exe
完整的示例:
@echo offcall "D:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/vcvars32.bat"rmdir /s/q ../src/buildlibmkdir ../src/buildlibcd ../src/buildlibqmake ../JWLib_qt/JWLib_qt.pro -spec win32-msvc2013 "CONFIG-=debug" "CONFIG+=release force_debug_info" "DEFINES+=JW_AWS"D:/Qt/qtcreator-4.2.1/bin/jom qmake_allnmake -f Makefile.Releasermdir /s/q ../buildjoymkdir ../buildjoycd ../buildjoyqmake ../joywok_qt/joywok_qt.pro -spec win32-msvc2013 "CONFIG-=debug" "CONFIG+=release force_debug_info" "DEFINES+=JW_AWS"D:/Qt/qtcreator-4.2.1/bin/jom qmake_allnmake -f Makefile.Release
rem 拷贝文件并打包
cd ../../setupdel ../bin/app/YWdatabase.dbrmdir /s/q ../bin/app/cachermdir /s/q ../bin/app/logrmdir /s/q ../bin/app/skinrmdir /s/q ../bin/app/qmlmkdir ../bin/app/skinmkdir ../bin/app/qmlxcopy ../bin/QDebug/skin/* ../bin/app/skin /excopy ../bin/QDebug/qml/* ../bin/app/qml /ecopy ../lib/Release/JWLib_qt.dll ../bin/appcopy ../bin/Release/Joywok.exe ../bin/apprmdir /s/q ../bin/app/crashesset year=%date:~0,4%set month=%date:~5,2%set day=%date:~8,2%set hour=%time:~0,2%set minute=%time:~3,2%set second=%time:~6,2%set ymd=%year%%month%%day%_%hour%%minute%%second%cd ../crashlogmd "%ymd%"copy /y ../lib/Release/jwlib_qt.pdb "%ymd%"copy /y ../bin/Release/joywok.pdb "%ymd%"copy /y ../lib/Release/JWLib_qt.dll "%ymd%"copy /y ../bin/Release/Joywok.exe "%ymd%"cd ../setuprem 签名signtool sign /f codesign.cer ../bin/app/JWLib_qt.dllsigntool sign /f codesign.cer ../bin/app/Joywok.exerem 打包del app.7zdel setup.exe../software/7-Zip/7z.exe a -t7z app.7z ../bin/app/*../software/NSIS/makensis.exe setup.nsisigntool sign /f codesign.cer setup.exerem 修改软件名称cd ..for /f "delims=" %%i in ('git rev-list HEAD --count') do (set "buildversion=%%i")echo %buildversion%cd setupset year=%date:~0,4%set month=%date:~5,2%set day=%date:~8,2%set ymd=%year%%month%%day%-b%buildversion%ren setup.exe joywok-aws-setup-%ymd%.exepause
总结
以上所述是小编给大家介绍的Windows程序打包脚本[bat]的详细流程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对VEVB武林网网站的支持!
注:相关教程知识阅读请移步到服务器教程频道。