프로그램들을 보면 빌드넘버를 제공하는 것을 볼 수 있습니다. 윈도우도 빌드넘버 2703등으로 빌드넘버를 제공하고 있습니다. 그러면 그런 프로그램들은 빌드를 할때 마다 1씩 어떻게 증가시켰는지 궁금하실텐데... 그러한 기능을 해주는 VC++ 매크로가 있어서 소개해 드립니다..
아래 페이지를 참고하시면 방법을 알 수 있습니다. 저는 첫번째 방법으로 VC++ 6.0에서 테스트 해보니 잘 되는 것을 확인했습니다. 가장 뒷번호가 빌드넘버가 되는 구성입니다. 한번쯤 프로젝트에 적용시켜보는 것도 재밌을것 같습니다.
msdn에서 해당 기능을 소개하고 있는 페이지 입니다. http://support.microsoft.com/default.aspx?scid=kb;en-us;237870
비슷한 방법을 설명한 페이지 입니다. http://www.codeproject.com/macro/autobuild.asp
닷넷에서 사용할 수 있는 방법을 설명한 페이지입니다. http://www.codeguru.com/Csharp/.NET/net_vs_addins/visualstudioadd-ins/article.php/c5959
실제로 적용하기에는 문제가 있는 부분이 앞쪽 메이저 버전을 바꾸기가 쉽지 않다는 점 입니다. 매번 versionno.h를 열어서 바꿔줘야 하는데 불편함이 있죠. 년월일로 버전을 구성하도록 수정한 매크로 파일입니다. 년도, 월, 일, 빌드넘버로 자동 구성해 줍니다. 위의 msdn에서 제공하고 있는 버전에서 ReplaceText 부분만 수정한 것 입니다.
' ------------------------------------------------------------------------------ ' FILE DESCRIPTION: version ' ------------------------------------------------------------------------------ Function GetProjectDir(FullName) ' VC++ doesn't provide any method for getting the path of the active project ' See the VB Script reference for more information on the VB Script functions ' used in this function Dim proj_path proj_path = Split(StrReverse(FullName),"",-1,1) Dim count count = UBound(proj_path) Dim full_path full_path = "" Dim i for i = 1 to count full_path = full_path & "" & proj_path(i) next GetProjectDir = StrReverse(full_path) End Function
Sub ReplaceText(selection, count, incrementby) ' selection represents the TextSelection object ' count represents the position of the version number to be incremented ' incrementby represents a number that will be added to the existing version number selection.WordRight dsMove, count selection.WordRight dsExtend, 1 selection.Text = Year(Now) selection.WordRight dsMove, 1 selection.WordRight dsExtend, 1 selection.Text = Month(Now) selection.WordRight dsMove, 1 selection.WordRight dsExtend, 1 selection.Text = Day(Now) selection.WordRight dsMove, 1 selection.WordRight dsExtend, 1 Dim str str = selection.Text str = str + incrementby selection.Text = str End Sub
Sub Application_BuildFinish(numError, numWarning) ' This event will be triggered after every build of a project ' You can check numError and/or numWarning to determine if you want to continue ' If numError <> 0 Then 'exit sub ' Obtain the full path of the active project Dim full_path full_path = GetProjectDir(ActiveProject.FullName) full_path = full_path & "versionno.h" ' Open the VersionNo.h file Documents.Open full_path ' Obtain the TextSelection object Dim selection set selection = ActiveDocument.Selection selection.StartOfDocument ' Increment the version information ReplaceText selection, 3, 1 selection.LineDown selection.StartOfLine ReplaceText selection, 3, 1 selection.LineDown selection.StartOfLine ReplaceText selection, 4, 1 selection.LineDown selection.StartOfLine ReplaceText selection, 4, 1 ActiveDocument.Save ActiveDocument.Close End Sub |
Tags: autobuild build version 윈도우즈
|