发布VC软件时,需要在编译机器上配置好Directory参数(包括lib和include);
执行项目编译脚本,即可生成目标文件;
build.bat脚本如下:(这是为Android手机和IOS手机做推送信息的后台服务程序的编译脚本)
@rem 编译环境
@rem 安装mysql驱动,openssl。
@rem VC配置“路径” 》include路径包含 mysql头文件目录,openssl头文件目录;
@rem 》lib路径包含 mysql的lib目录, openssl lib目录;
@rem ######################输出目录
@if not exist Release md Release
@set m_time=%time%
@set hh=%m_time:~0,2%
@if /i %hh% LSS 10 (set hh=0%time:~1,1%)
@set log=.\Release\%date:~0,4%%date:~5,2%%date:~8,2%%hh%%time:~3,2%%time:~6,2%_buildlog
@md %log%
@set logpath=%log%\
@echo on
@rem #######################编译模块
@set name=Notification4Android_dll_debug.log
msdev .\Notification4Android\Pushinfodll\pushinfo.dsw /make "pushinfo - Win32 Debug" /REBUILD /OUT %logpath%%name%
@set name=Notification4Android_dll_release.log
msdev .\Notification4Android\Pushinfodll\pushinfo.dsw /make "pushinfo - Win32 Release MinDependency" /REBUILD /OUT %logpath%%name%
@set name=Notification4Android_service_debug.log
msdev .\Notification4Android\pushservice\pushservice.dsw /make "pushservice - Win32 Debug" /REBUILD /OUT %logpath%%name%
@set name=Notification4Android_service_release.log
msdev .\Notification4Android\pushservice\pushservice.dsw /make "pushservice - Win32 Release MinDependency" /REBUILD /OUT %logpath%%name%
@set name=Notification4Android_monitor_release.log
msdev .\ServerMonitor\ServerMonitor.dsw /make "ServerMonitor - Win32 Release MinDependency" /REBUILD /OUT %logpath%%name%
XCOPY .\Notification4Android\pushservice\sysconfig.ini .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\install_pushservice.bat .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\Uninstall_pushservice.bat .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\start_pushservice.bat .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\stop_pushservice.bat .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\libmysql.dll .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\ReleaseMinDependency\pushservice.exe .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\ReleaseMinDependency\pushinfo.dll .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\ReleaseMinDependency\pushinfo.pdb .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\ReleaseMinDependency\pushinfo.map .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\registerdll.bat .\release\4Android_release\ /h /d /q /y
XCOPY .\Notification4Android\Unregisterdll.bat .\release\4Android_release\ /h /d /q /y
@rem XCOPY .\ServerMonitor\ReleaseMinDependency\ServerMonitor.exe .\release\4Android_release\. /h /d /q /y
XCOPY .\Notification4Android\pushservice\sysconfig.ini .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\install_pushservice.bat .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\Uninstall_pushservice.bat .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\start_pushservice.bat .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\stop_pushservice.bat .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\libmysql.dll .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\pushservice\Debug\pushservice.exe .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\Debug\pushinfo.dll .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\Debug\pushinfo.pdb .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\Pushinfodll\Debug\pushinfo.map .\release\4Android_debug\ /h /d /q /y
XCOPY .\Notification4Android\registerdll.bat .\release\4Android_debug\. /h /d /q /y
XCOPY .\Notification4Android\Unregisterdll.bat .\release\4Android_debug\. /h /d /q /y
@rem XCOPY .\ServerMonitor\ReleaseMinDependency\ServerMonitor.exe .\release\4Android_debug\. /h /d /q /y
@rem XCOPY .\\stlport_vc646.dll .\release /h /d /q /y
@set name=Notification4IOS_dll_debug.log
msdev .\Notification4IOS\NotificationDll\NotificationDll.dsw /make "NotificationDll - Win32 Debug" /REBUILD /OUT %logpath%%name%
@set name=Notification4IOS_dll_release.log
msdev .\Notification4IOS\NotificationDll\NotificationDll.dsw /make "NotificationDll - Win32 Release MinDependency" /REBUILD /OUT %logpath%%name%
@set name=Notification4IOS_service_debug.log
msdev .\Notification4IOS\NotificationService\NotificationService.dsw /make "NotificationService - Win32 Debug" /REBUILD /OUT %logpath%%name%
@set name=Notification4IOS_service_release.log
msdev .\Notification4IOS\NotificationService\NotificationService.dsw /make "NotificationService - Win32 Release MinDependency" /REBUILD /OUT %logpath%%name%
XCOPY .\Notification4IOS\NotificationService\sysconfig.ini .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\install_Notificationservice.bat .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\Uninstall_Notificationservice.bat .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\start_Notificationservice.bat .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\stop_Notificationservice.bat .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libmysql.dll .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libeay32.dll .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libssl32.dll .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\ssleay32.dll .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\ReleaseMinDependency\NotificationService.exe .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\ReleaseMinDependency\NotificationDll.dll .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\ReleaseMinDependency\NotificationDll.pdb .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\ReleaseMinDependency\NotificationDll.map .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\registerdll.bat .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\Unregisterdll.bat .\release\4IOS_release\ /h /d /q /y
@rem XCOPY .\ServerMonitor\ReleaseMinDependency\ServerMonitor.exe .\release\4IOS_release\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\sysconfig.ini .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\install_Notificationservice.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\Uninstall_Notificationservice.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\start_Notificationservice.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\stop_Notificationservice.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libmysql.dll .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libeay32.dll .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\libssl32.dll .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\ssleay32.dll .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationService\Debug\NotificationService.exe .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\Debug\NotificationDll.dll .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\Debug\NotificationDll.pdb .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\NotificationDll\Debug\NotificationDll.map .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\registerdll.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\Notification4IOS\Unregisterdll.bat .\release\4IOS_debug\ /h /d /q /y
XCOPY .\ServerMonitor\ReleaseMinDependency\ServerMonitor.exe .\release\ /h /d /q /y
XCOPY .\ServerMonitor\install_monitor_service.bat .\release\ /h /d /q /y
XCOPY .\ServerMonitor\start_monitor_server.bat .\release\ /h /d /q /y
XCOPY .\ServerMonitor\stop_monitor_server.bat .\release\ /h /d /q /y
XCOPY .\ServerMonitor\Uninstall_monitor_service.bat .\release\ /h /d /q /y
@echo build is completed
pause
还有一个问题就是项目版本升级,要更新版本号:
版本号在rc文件中,一个简单的方法是:直接替换版本号。
#升级版本ruby脚本
#
#作者:jordan .sg 2012-8-31
#require "stringio"
File.open("./Notification4Android/Pushinfodll/pushinfo.rc", "r") do |rcfile| # Open file out.txt for writing
str=rcfile.read
str.gsub!('1,0,0,4','1,0,0,5')
str.gsub!('1, 0, 0, 4','1, 0, 0, 5')
rcfile.close
File.open("./pushinfo.rc", "w") do |rcfile|
rcfile.write(str)
rcfile.flush
rcfile.close
end
end
File.open("./Notification4IOS/NotificationDll/NotificationDll.rc", "r") do |rcfile| # Open file out.txt for writing
str=rcfile.read
str.gsub!('1,0,0,0','1,0,0,1')
str.gsub!('1, 0, 0, 0','1, 0, 0, 1')
rcfile.close
File.open("./pushinfo.rc", "w") do |rcfile|
rcfile.write(str)
rcfile.flush
rcfile.close
end
end