Windows程序打包脚本[bat]的详细流程
打包脚本的流程和自动打包基本相同:
1.编译软件
2.拷贝需要的内容
3.代码签名
4.打包成安装文件
5.再次签名,并将安装文件名称改成需要的格式
------------------------------------------------------------------
编译软件需要初始化vs的运行环境,如
call"D:\ProgramFiles(x86)\MicrosoftVisualStudio12.0\VC\bin\vcvars32.bat"
然后开编译。
编译完成,拷贝文件,使用signtool对软件进行签名,
signtoolsign/fcodesign.cer..\bin\app\Joywok.exe
最后将其修改为需要的命名风格,这里使用了gitrev-listHEAD--count来获取git的提交次数作为buildversion
rem修改软件名称
for/f"delims="%%iin('gitrev-listHEAD--count')do(
set"buildversion=%%i"
)
echo%buildversion%
cdsetup
setyear=%date:~0,4%
setmonth=%date:~5,2%
setday=%date:~8,2%
setymd=%year%%month%%day%-b%buildversion%
rensetup.exejoywok-aws-setup-%ymd%.exe
完整的示例:
@echooff call"D:\ProgramFiles(x86)\MicrosoftVisualStudio12.0\VC\bin\vcvars32.bat" rmdir/s/q..\src\buildlib mkdir..\src\buildlib cd..\src\buildlib qmake..\JWLib_qt\JWLib_qt.pro-specwin32-msvc2013"CONFIG-=debug""CONFIG+=releaseforce_debug_info""DEFINES+=JW_AWS" D:\Qt\qtcreator-4.2.1\bin\jomqmake_all nmake-fMakefile.Release rmdir/s/q..\buildjoy mkdir..\buildjoy cd..\buildjoy qmake..\joywok_qt\joywok_qt.pro-specwin32-msvc2013"CONFIG-=debug""CONFIG+=releaseforce_debug_info""DEFINES+=JW_AWS" D:\Qt\qtcreator-4.2.1\bin\jomqmake_all nmake-fMakefile.Release
rem拷贝文件并打包
cd..\..\setup
del..\bin\app\YWdatabase.db
rmdir/s/q..\bin\app\cache
rmdir/s/q..\bin\app\log
rmdir/s/q..\bin\app\skin
rmdir/s/q..\bin\app\qml
mkdir..\bin\app\skin
mkdir..\bin\app\qml
xcopy..\bin\QDebug\skin\*..\bin\app\skin/e
xcopy..\bin\QDebug\qml\*..\bin\app\qml/e
copy..\lib\Release\JWLib_qt.dll..\bin\app
copy..\bin\Release\Joywok.exe..\bin\app
rmdir/s/q..\bin\app\crashes
setyear=%date:~0,4%
setmonth=%date:~5,2%
setday=%date:~8,2%
sethour=%time:~0,2%
setminute=%time:~3,2%
setsecond=%time:~6,2%
setymd=%year%%month%%day%_%hour%%minute%%second%
cd..\crashlog
md"%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..\setup
rem签名
signtoolsign/fcodesign.cer..\bin\app\JWLib_qt.dll
signtoolsign/fcodesign.cer..\bin\app\Joywok.exe
rem打包
delapp.7z
delsetup.exe
..\software\7-Zip\7z.exea-t7zapp.7z..\bin\app\*
..\software\NSIS\makensis.exesetup.nsi
signtoolsign/fcodesign.cersetup.exe
rem修改软件名称
cd..
for/f"delims="%%iin('gitrev-listHEAD--count')do(
set"buildversion=%%i"
)
echo%buildversion%
cdsetup
setyear=%date:~0,4%
setmonth=%date:~5,2%
setday=%date:~8,2%
setymd=%year%%month%%day%-b%buildversion%
rensetup.exejoywok-aws-setup-%ymd%.exe
pause
总结
以上所述是小编给大家介绍的Windows程序打包脚本[bat]的详细流程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!