• Windows程序打包脚本[bat]


    打包脚本的流程和自动打包基本相同:

    1. 编译软件

    2. 拷贝需要的内容

    3. 代码签名

    4. 打包成安装文件

    5. 再次签名,并将安装文件名称改成需要的格式

    ------------------------------------------------------------------

    编译软件需要初始化vs的运行环境,如

    call "D:Program Files (x86)Microsoft Visual Studio 12.0VCinvcvars32.bat"

    然后开编译。

    编译完成,拷贝文件,使用signtool对软件进行签名,

    signtool sign /f codesign.cer ..inappJoywok.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 setup
    set 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 off
    call "D:Program Files (x86)Microsoft Visual Studio 12.0VCinvcvars32.bat"
    rmdir /s/q ..srcuildlib
    mkdir ..srcuildlib
    cd ..srcuildlib
    qmake ..JWLib_qtJWLib_qt.pro -spec win32-msvc2013 "CONFIG-=debug" "CONFIG+=release force_debug_info" "DEFINES+=JW_AWS"
    D:Qtqtcreator-4.2.1injom qmake_all
    nmake -f Makefile.Release
    
    
    rmdir /s/q ..uildjoy
    mkdir ..uildjoy
    cd ..uildjoy
    qmake ..joywok_qtjoywok_qt.pro -spec win32-msvc2013 "CONFIG-=debug" "CONFIG+=release force_debug_info" "DEFINES+=JW_AWS"
    D:Qtqtcreator-4.2.1injom qmake_all
    nmake -f Makefile.Release
    
    
    rem 拷贝文件并打包
    cd ....setup
    
    del ..inappYWdatabase.db
    rmdir /s/q ..inappcache
    rmdir /s/q ..inapplog
    rmdir /s/q ..inappskin
    rmdir /s/q ..inappqml
    mkdir ..inappskin
    mkdir ..inappqml
    xcopy ..inQDebugskin* ..inappskin /e
    xcopy ..inQDebugqml* ..inappqml /e
    copy ..libReleaseJWLib_qt.dll ..inapp
    copy ..inReleaseJoywok.exe ..inapp
    rmdir /s/q ..inappcrashes
    set 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 ..crashlog
    md "%ymd%"
    copy /y ..libReleasejwlib_qt.pdb "%ymd%"
    copy /y ..inReleasejoywok.pdb "%ymd%"
    copy /y ..libReleaseJWLib_qt.dll "%ymd%"
    copy /y ..inReleaseJoywok.exe "%ymd%"
    
    cd ..setup
    rem 签名
    signtool sign /f codesign.cer ..inappJWLib_qt.dll
    signtool sign /f codesign.cer ..inappJoywok.exe
    
    rem 打包
    del app.7z
    del setup.exe
    ..software7-Zip7z.exe a -t7z app.7z ..inapp*
    ..softwareNSISmakensis.exe setup.nsi
    
    signtool sign /f codesign.cer setup.exe
    
    rem 修改软件名称
    cd ..
    for /f "delims=" %%i in ('git rev-list HEAD --count') do (
    set "buildversion=%%i"
    )
    
    echo %buildversion%
    cd setup
    set 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
    
    pause
  • 相关阅读:
    mongodb的aggregate聚合操作详解
    2013, Lost connection to MySQL server during query
    事务失败的重试策略
    mongodb的shell脚本
    mongodb的currentOp
    mongodb插入数据
    Too many threads are already waiting
    connection timed out
    python3-request.session 的使用
    intellij-永久破解最新版本idea 2020.3.1
  • 原文地址:https://www.cnblogs.com/vectorli/p/7081666.html
Copyright © 2020-2023  润新知