InstallShield安装打包编译自动化(1) - 通过命令行进行源代码控制操作

游刃有余 发布于 2010/08/25 11:22
阅读 1K+
收藏 1

近期正在研究InstallShield中的自动化过程,今天先与大家分享一下InstallShield自带帮助中一节内容:

 

前提:

1. 使用Microsoft Visual SourceSafe进行应用程序源码管理,

2. 实现使用VBScript。

 
获取最新版本的InstallShield工程并编译安装包

    Const VSSFLAG_USERRONO   = 1

    Const VSSFLAG_TIMEMOD    = 8

    Const VSSFLAG_REPREPLACE = 128


    Const PROJECT_SCC_INI_LOC = "\\Server\srcsafe.ini"

    Const PROJECT_SCC_FOLDER = "$/MyFiles/"

    Const PROJECT_SCC_BASE_NAME = "MyProject"

    Const PROJECT_SCC_LOCAL_FOLDER = "C:\Project"


    ' Create a ref to Microsoft Visual SourceSafe

    Set VSS = CreateObject("SourceSafe")

    ' Point to the VSS database

    VSS.open PROJECT_SCC_INI_LOC


    ' Get the project file

    Set VSSISVFile = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME + ".ism")

    VSSISVFile.Get PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME + ".ism", SSFLAG_TIMEMOD + VSSFLAG_USERRONO + VSSFLAG_REPREPLACE


    'Get all remaining files

    Set VSSIDTFolder = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME)

    VSSIDTFolder.LocalSpec = PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME

    For Each VSSObj In VSSIDTFolder.Items(False)

        VSSObj.Get , VSSFLAG_TIMEMOD + VSSFLAG_USERRONO + VSSFLAG_REPREPLACE

    Next


    strFileBasePath = PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME + ".ism"

    strCmdLine = "ISCmdBld.exe -p """ + strFileBasePath + ".ism"""

    ' Build your installation

    Set wshshell = CreateObject("Wscript.Shell")

    RunCmdLine = wshshell.Run(strCmdLine, 1, True)

 
安装包工程代码Check Out,修改,Check In

    Const VSSFLAG_USERRONO = 1

    Const VSSITEM_FILE     = 1


    Const PROJECT_SCC_INI_LOC = "\\Server\srcsafe.ini"

    Const PROJECT_SCC_FOLDER = "$/MyFiles/"

    Const PROJECT_SCC_BASE_NAME = "MyProject"

    Const PROJECT_SCC_LOCAL_FOLDER = "C:\Project"


    ' Create a ref to Microsoft Visual SourceSafe

    Set VSS = CreateObject("SourceSafe")

    ' Point to the VSS database

    VSS.open PROJECT_SCC_INI_LOC


    ' Check out the project file

    Set VSSISVFile = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME + ".ism")

    VSSISVFile.CheckOut , PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME + ".ism", VSSFLAG_USERRONO


    'Check out all remaining files

    Set VSSIDTFolder = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME)

    VSSIDTFolder.LocalSpec = PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME

    For Each VSSObj In VSSIDTFolder.Items(False)

        If VSSObj.Type = VSSITEM_FILE Then

            VSSObj.CheckOut , , VSSFLAG_USERRONO

        End If

    Next


    ' Create a reference to the InstallShield Automation Interface

    Set m_ISWiProject = CreateObject("IswiAuto16.ISWiProject")

    strFileBasePath = PROJECT_SCC_LOCAL_FOLDER + PROJECT_SCC_BASE_NAME + ".ism"

    ' Open your project

    m_ISWiProject.OpenProject strFileBasePath

    ' Add a feature

    m_ISWiProject.AddFeature "Robofeature1"

    ' Save the project

    m_ISWiProject.SaveProject

    ' Close the project

    m_ISWiProject.CloseProject


    ' Check in the project file

    Set VSSISVFile = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME + ".ism")

    VSSISVFile.CheckIn


    'Check in all remaining files

    Set VSSIDTFolder = VSS.VSSItem (PROJECT_SCC_FOLDER + PROJECT_SCC_BASE_NAME)

    For Each VSSObj In VSSIDTFolder.Items(False)

        If VSSObj.Type = VSSITEM_FILE Then

            VSSObj.CheckIn "Check In Comment"

        End If

    Next

 

在学习安装打包技术的兄弟们,可看看Appinstall中文论坛(www.appinstall.cn),可学到不少东西

加载中
返回顶部
顶部