• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 64, 文章 - 11, 評論 - 12, 引用 - 0
            數(shù)據(jù)加載中……

            管理項(xiàng)目的版本號

                  現(xiàn)在,很多公司都是在用免費(fèi)的SVN工具來管理版本。如何讓可執(zhí)行程序與DLL的信息與生成時(shí)的SVN版本相對應(yīng)呢?以便于更好地跟蹤項(xiàng)目呢?在原來我是用一段腳本來實(shí)現(xiàn)的。
            分為Version.h, Version.rc,和一段腳本。
            //Version.h
            #define SHADOW_MAJOR_VERSION 4
            #define SHADOW_MINOR_VERSION 5
            #define SHADOW_BETA_MAJOR_VERSION 7
            #define SHADOW_BETA_MINOR_VERSION 155
            #define SHADOW_VERSION "4.5.7.155"
            #define SHADOW_REVISION "0"

            在version.rc中,包含Version.h并把相應(yīng)的版本信息用上面的SHADOW_REVISION及 SHADOW_VERSION賦值

             1' Set the revision for the application
             2' 
             3
             4' Get File path
             5scriptName = wscript.scriptfullname
             6scriptPath = Left(scriptName, instrRev(scriptName, "\"))
             7
             8' create svn object and get the last revision
             9Set svnObj = CreateObject("SubWCRev.object")
            10svnObj.GetWCInfo scriptPath,0,0
            11versionDes = "Revision: " & svnObj.Revision & ". Date:" & svnObj.Date
            12
            13' update the version.h with the lastest version
            14Set fs = CreateObject("Scripting.FileSystemObject")
            15scriptPath = Left(scriptPath, Len(scriptPath) -1)
            16slnPath = Left(scriptName, instrRev(scriptPath, "\"))
            17versionFullName = slnPath & "Version.h"
            18
            19' check file valid
            20If Not fs.fileexists(versionFullName) Then
            21    MsgBox "The file version.h does not exists."
            22    wscript.quit
            23End If
            24
            25' read content from the file
            26Set fRead = fs.OpenTextFile(versionFullName, 1)
            27fContent = fRead.ReadAll
            28fRead.close
            29
            30' modify the revision value
            31Set regEx = New RegExp
            32regEx.Pattern = "#define\s+SHADOW_REVISION\s+""(.*)"""
            33Set Matches = regEx.Execute(fContent)
            34For Each Match in Matches  
            35      RetStr = RetStr & "Match found at position "
            36      RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
            37      RetStr = RetStr & Match.Value & "'." & vbCRLF
            38      If Match.submatches(0= versionDes Then
            39          MsgBox "The revision is already lastest"
            40          wscript.quit
            41      End If
            42Next
            43fContent = regEx.Replace(fContent, "#define SHADOW_REVISION """ & versionDes & """")
            44
            45' Write to version.h
            46Set fWrite = fs.OpenTextFile(versionFullName, 2)
            47fWrite.Write fContent
            48fwrite.close
            49MsgBox "Update the revision successful"

            可以看出實(shí)現(xiàn)起來比較麻煩。
            這里介紹一種新的方法。新添一個(gè)模板文件,格式如下。
             1/*
             2    Substitution keyword file for SubWCRev (part of Tortoise SVN), to autochange version number with SVN Rev number
             3*/

             4
             5#pragma once
             6
             7
             8#define  _ProductVersion "3.0.0.1"
             9#define  _FileVersion "3.2.0.$WCREV$";
            10#define  _Revision  "$WCREV$";
            11#define  _Modified  "$WCMODS?Modified:Not modified$";
            12#define  _Date      "$WCDATE$";
            13#define  _Range     "$WCRANGE$";
            14#define  _Mixed     "$WCMIXED?Mixed revision WC:Not mixed$";
            15#define  _URL       "$WCURL$";
            16#define  _ProductName  "Software 1.0"
            17#define  _CompanyName   "Company"
            18#define  _FileDescription "SoftWare module"
            19#define  _LegalCopyright "Company, All rights reserved."
            20#define  _FileVersion_0  3
            21#define  _FileVersion_1  2
            22#define  _FileVersion_2  0
            23#define  _FileVersion_3  $WCREV$
            24#define  _ProductVersion_0  3
            25#define  _ProductVersion_1  2
            26#define  _ProductVersion_2  0
            27#define  _ProductVersion_3  1

            在打包時(shí)運(yùn)行如下的批處理文件就會自動生成或者更新version.h
            SubWCRev.exe ..\ SubWCRev.txt ..\version.h

            pause

            資源文件還是引用version.h定義好的常量。這種方式就很簡單,而且不易出錯(cuò)。上面介紹C++方面的版本跟蹤,在C#中則是先制定AssemblyInfo.cs的一個(gè)模板,在打包時(shí)用上面的命令去更新AssemblyInfo.cs。

            posted on 2009-04-24 10:45 Robertxiao 閱讀(832) 評論(0)  編輯 收藏 引用 所屬分類: 天馬行空

            久久精品国产免费| 三级韩国一区久久二区综合 | 亚洲七七久久精品中文国产| 久久男人中文字幕资源站| 奇米影视7777久久精品人人爽| 五月丁香综合激情六月久久 | 性高朝久久久久久久久久| 久久九九久精品国产免费直播| 精品久久一区二区| 亚洲国产精品无码久久九九| 色综合久久无码五十路人妻| 大美女久久久久久j久久| 人妻无码αv中文字幕久久 | 香蕉久久夜色精品升级完成| 国产精品日韩深夜福利久久| 久久精品一区二区三区AV| 亚洲国产精品久久久久| 亚洲午夜久久久久久久久久| 精品久久久久中文字幕一区| 少妇内射兰兰久久| 国产精品欧美亚洲韩国日本久久| 亚洲人成精品久久久久| 久久精品国产精品亚洲人人| 狠色狠色狠狠色综合久久| 中文国产成人精品久久不卡| 伊人伊成久久人综合网777| 国产日韩欧美久久| 国产成人久久精品麻豆一区| 久久91精品国产91久久小草 | 99久久精品国产高清一区二区 | 韩国免费A级毛片久久| 国产69精品久久久久久人妻精品| 久久久久九九精品影院| 99精品久久久久久久婷婷| 四虎国产精品免费久久5151| 久久久噜噜噜久久中文福利| 久久天天躁狠狠躁夜夜96流白浆| 亚洲狠狠婷婷综合久久蜜芽| 亚洲精品乱码久久久久久中文字幕| 伊人热热久久原色播放www| 性做久久久久久久久浪潮|