1.BuildRelease.bat
用于不开启VS直接编译、部署、创建和恢复快照 WindowsPhone APP,注册WindowsPhone手机。
进行了编译和部署的效果:
BuildRelease.bat
1 @echo off 2 pushd "%~dp0" 3 title Build Release 4 set folder=%CD% 5 set MSBUILD=%windir%\microsoft.net\framework\v4.0.30319\msbuild.exe 6 set APPDEPLOYCMD="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeployCmd.exe" 7 set APPDEPLOY="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.1\Tools\AppDeploy\AppDeploy.exe" 8 set ISETOOL="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.1\Tools\IsolatedStorageExplorerTool\isetool.exe" 9 set PHONEREG="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.1\Tools\Phone Registration\PhoneReg.exe" 10 set PRODUCTID=6d24eb8a-60e9-4d9c-a943-f6d5c7796649 11 set DESKTOPPATH=myfiles 12 set XAPFILE="%folder%\Youku.Bin\Release\Youku_Release_ARM.xap" 13 set msbuildlog="%folder%\lastmsbuild.log" 14 set filelogger=/fl /flp:logfile=%msbuildlog% 15 if "%folder%"=="" goto :edit 16 if NOT EXIST %folder% goto :edit 17 :menu 18 echo. 19 echo Target: %folder% 20 echo ^
BuildRelease_8.0.bat (WindowsPhone 8.0版本)
1 @echo off 2 pushd "%~dp0" 3 title Build Release for WP8.0 4 set folder=%CD% 5 set MSBUILD=%windir%\microsoft.net\framework\v4.0.30319\msbuild.exe 6 set XAPDEPLOYCMD="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\XAP Deployment\XapDeployCmd.exe" 7 set XAPDEPLOY="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\XAP Deployment\XapDeploy.exe" 8 set ISETOOL="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplorerTool\isetool.exe" 9 set PHONEREG="%ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\Phone Registration\PhoneReg.exe" 10 set PRODUCTID=6d24eb8a-60e9-4d9c-a943-f6d5c7796649 11 set DESKTOPPATH=myfiles 12 set XAPFILE="%folder%\Youku.Bin\Release\Youku_Release_ARM.xap" 13 set msbuildlog="%folder%\lastmsbuild.log" 14 set filelogger=/fl /flp:logfile=%msbuildlog% 15 if "%folder%"=="" goto :edit 16 if NOT EXIST %folder% goto :edit 17 :menu 18 echo. 19 echo Target: %folder% 20 echo ^
View Code
2.拷贝项目副本.bat
用于创建项目副本。比如开发新版本时,用ROBOCOPY在本地复制一份出来。
效果如图:
拷贝项目副本.bat
1 @echo off 2 echo --------------------------------- 3 echo ROBOCOPY source-dir dest-dir /MIR 4 echo --------------------------------- 5 title ROBOCOPY source-dir dest-dir 6 :setsource 7 set /p source=source-dir: 8 if "%source%"=="" goto :setsource 9 if not exist %source% echo The source-dir doesn't exist. Please input again.&&goto :setsource10 title ROBOCOPY %source% dest-dir11 :setdestination12 set /p destination=dest-dir:13 if "%destination%"=="" goto :setdestination14 if not exist %destination% goto :startrobocopy15 :overwritequestion16 set /p key=The dest-dir has existed. Do it?(Y/N):17 if "%key%"=="" goto :overwritequestion18 if "%key%"=="Y" goto :startrobocopy19 if "%key%"=="y" goto :startrobocopy20 goto :setdestination21 :startrobocopy22 title ROBOCOPY %source% %destination%23 set XF=Thumbs.db24 set XD=.svn myfiles25 robocopy %source% %destination% /MIR /XF %XF% /XD %XD%26 title ROBOCOPY %source% %destination% (Completed)27 set /p key=Press ENTER to open folder...28 explorer /select,"%destination%\BuildRelease.bat"
创建项目NOKIA包.bat
其中包含了文件名大写、Unicode代码替换功能,替换图像等文件按项目文件结构放在 wp8nokiaupdate 文件夹中。
1 @echo off 2 echo --------------------------- 3 echo Create Project-Nokia 4 echo --------------------------- 5 title Create Project-Nokia 6 color 17 7 :setsource 8 set /p source=source-dir: 9 if "%source%"=="" goto :setsource10 if not exist %source% echo The source-dir doesn't exist. Please input again.&&goto :setsource11 :setdestination12 set "destination=%source:wp8_v=诺基亚wp8_v%"13 for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do call set destination=%%destination:%%i=%%i%%14 if "%destination%"=="" goto :setdestination15 if not exist %destination% goto :startrobocopy16 :overwritequestion17 set /p key=The dest-dir has existed. Do it?(Y/N):18 if "%key%"=="" goto :overwritequestion19 if "%key%"=="Y" goto :startrobocopy20 if "%key%"=="y" goto :startrobocopy21 goto :setsource22 :startrobocopy23 color 2e24 set XF=Thumbs.db25 set XD=.svn myfiles26 robocopy %source% %destination% /MIR /XF %XF% /XD %XD%27 if not exist wp8nokiaupdate goto :editAppid28 echo ^>^> Xcopying wp8nokiaupdate files...29 xcopy wp8nokiaupdate %destination%\ /s /e /g /h /r /k /y30 :editAppid31 rem echo ^>^> Replace AppId, MarketPlaceAppId, IdleDetectionMode, Agree for Terms and Privacy...32 echo ^>^> Replace AppId, MarketPlaceAppId...33 set sourceappid=ad00404c17cb662e34 set nokiaappid=515158cd5f9b803b35 set sourcemarketplaceappid=cdfb7d0f-825e-40b4-b146-3853a064699436 set nokiamarketplaceappid=923aa42b-882c-4815-9c69-b74100cac3c937 set replacefile1=%destination%\Youku.Online\YoukuService\YoukuServicePartOne.cs38 rem set replacefile2=%destination%\Youku\App.xaml.cs39 rem set replacefile3=%destination%\Youku\Views\UserRegisterPageView.xaml40 set tempvbs=%~n0_replace_appid.vbs41 echo function ansi2utf8(strFile,s1,s2,newname) >%tempvbs%42 echo Set ADOStrm = CreateObject("ADODB.Stream") >>%tempvbs%43 echo ADOStrm.Type = 2 >>%tempvbs%44 echo ADOStrm.Mode = 3 >>%tempvbs%45 echo ADOStrm.CharSet = s1 >>%tempvbs%46 echo ADOStrm.Open >>%tempvbs%47 echo ADOStrm.LoadFromFile strFile >>%tempvbs%48 echo s = ADOStrm.ReadText >>%tempvbs%49 echo ADOStrm.Position = 0 >>%tempvbs%50 echo ADOStrm.CharSet = s2 >>%tempvbs%51 echo ADOStrm.WriteText s >>%tempvbs%52 echo ADOStrm.SetEOS >>%tempvbs%53 echo ADOStrm.SaveToFile newname, 2 >>%tempvbs%54 echo ADOStrm.Close >>%tempvbs%55 echo end function >>%tempvbs%56 echo function strReplace(pFile,pStr,reStr) >>%tempvbs%57 echo set fso=CreateObject("Scripting.FileSystemObject") >>%tempvbs%58 echo set ws=CreateObject("wscript.shell") >>%tempvbs%59 echo filename=pFile >>%tempvbs%60 echo ansi2utf8 filename,"utf-8","gbk","temp.tmp" >>%tempvbs%61 echo set fr=fso.opentextfile("temp.tmp",1,-1) >>%tempvbs%62 echo set fw=fso.createtextfile("temp2.tmp",2) >>%tempvbs%63 echo Set regEx = New RegExp >>%tempvbs%64 echo do >>%tempvbs%65 echo data=fr.readline >>%tempvbs%66 echo regEx.Pattern = pStr >>%tempvbs%67 echo data = regEx.Replace(data, reStr) >>%tempvbs%68 echo fw.writeline data >>%tempvbs%69 echo loop until fr.atendofstream >>%tempvbs%70 echo fw.close:fr.close >>%tempvbs%71 echo ansi2utf8 "temp2.tmp","gbk","utf-8",filename >>%tempvbs%72 echo fso.deletefile "temp.tmp",true >>%tempvbs%73 echo fso.deletefile "temp2.tmp",true >>%tempvbs%74 echo end function >>%tempvbs%75 echo strReplace "%replacefile1%","""%sourceappid%""","""%nokiaappid%""" >>%tempvbs%76 echo strReplace "%replacefile1%","""%sourcemarketplaceappid%""","""%nokiamarketplaceappid%""" >>%tempvbs%77 rem echo strReplace "%replacefile2%","PhoneApplicationService.Current.UserIdleDetectionMode","//PhoneApplicationService.Current.UserIdleDetectionMode" >>%tempvbs%78 rem echo strReplace "%replacefile2%","PhoneApplicationService.Current.ApplicationIdleDetectionMode","//PhoneApplicationService.Current.ApplicationIdleDetectionMode" >>%tempvbs%79 rem echo strReplace "%replacefile3%","Name=""acceptConventionCheckBox"" IsChecked=""True""","Name=""acceptConventionCheckBox"" IsChecked=""False""" >>%tempvbs%80 wscript %tempvbs%81 ping 127.1 -n 2 >nul82 del %tempvbs% /q>nul83 find /n /i "%nokiaappid%" %replacefile1%84 find /n /i "%nokiamarketplaceappid%" %replacefile1%85 if %ERRORLEVEL% NEQ 0 (echo ^>^> Replace AppId ERROR!) else (echo Replace AppId OK.)86 :completed87 echo Completed.88 title Create Project-Nokia (Completed)89 echo.90 color 1791 set /p key=Press ENTER to open folder...92 explorer /select,"%destination%\BuildRelease.bat"
View Code
3.制作备份.bat
利用7za.exe根据当前的时间进行源代码备份,可自动生成 exclude.txt 文件,去除源码中不需要备份的部分,也可以对它手动编辑。
需要下载7z的独立命令行工具7za.exe
效果如下:
制作备份.bat
1 @echo off 2 rem 说明: 3 rem slnDir [必选] 将压缩的文件夹名称 4 rem slnFile [可选] 将sln文件名(不含扩展名)设置在“slnFile=”右边 5 rem password [可选] 打包时使用的密码 6 ::call 制作备份.bat -noUplayer 7 ::call 制作备份.bat -onlyUplayer 8 set slnDir=wp8_v3.7 9 set slnFile=10 set password=youku12311 set output="%slnDir%.%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%-%time:~3,2%-%time:~6,2%.Src.7z"12 if "%slnFile%"=="" set slnFile=%slnDir%13 set exe7z=7za.exe14 set excludeFile=exclude.txt15 title 制作备份16 ::参数17 if "%1"=="-noUplayer" goto :noUplayer18 if "%1"=="-onlyUplayer" goto :onlyUplayer19 goto :start20 :noUplayer21 title 制作备份 - NO UPLAYER FOLDER22 set excludeFile=exclude_noUplayer.txt23 set output="%slnDir%.nouplayer.%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%-%time:~3,2%-%time:~6,2%.Src.7z"24 goto :start25 :onlyUplayer26 title 制作备份 - ONLY UPLAYER FOLDER27 set output="%slnDir%.UPlayer.%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%-%time:~3,2%-%time:~6,2%.Src.7z"28 set slnDir="%slnDir%\UPlayer"29 goto :start30 :start31 cls32 if "%slnDir%"=="" goto :ERR133 if not exist %slnDir% goto :ERR134 if not exist %exe7z% goto :ERR235 if exist %excludeFile% goto :COMPRESS36 ::生成excludeFile37 echo .svn\>%excludeFile%38 echo bin\>>%excludeFile%39 echo obj\>>%excludeFile%40 echo PerformanceLogs\>>%excludeFile%41 echo PerfLogs\>>%excludeFile%42 echo myfiles\>>%excludeFile%43 echo packages\>>%excludeFile%44 echo ipch\>>%excludeFile%45 echo *.sdf>>%excludeFile%46 echo Youku.suo>>%excludeFile%47 echo Youku.v11.suo>>%excludeFile%48 echo Youku.v12.suo>>%excludeFile%49 echo Youku.sln.DotSettings.user>>%excludeFile%50 echo lastmsbuild.log>>%excludeFile%51 echo Youku_*.sap>>%excludeFile%52 echo Youku.sdf>>%excludeFile%53 echo Thumbs.db>>%excludeFile%54 echo Youku_Debug_AnyCPU.xap>>%excludeFile%55 echo Youku_Release_AnyCPU.xap>>%excludeFile%56 if "%1"=="-noUplayer" echo UPlayer\>>%excludeFile%57 :COMPRESS58 title 正在备份:%output%59 if exist %output% del %output% /F /Q60 if "%password%"=="" (set pwd=) else (set pwd=-p%password%)61 %exe7z% a -t7z -mx=9 %output% "%slnDir%\" -xr@%excludeFile% -scsWIN %pwd%62 echo 输出文件:%output%63 title 备份完成:%output%64 set /p key=按回车键退出...65 goto :END66 :ERR167 title 错误 - 制作备份68 color 0E69 echo 错误:源文件夹:“%slnDir%” 不存在!70 echo.71 echo 请修改slnDir变量,保存后重试。72 echo.73 echo 按任意键开始编辑...74 pause>nul75 start "" %windir%\notepad.exe "%~0"76 goto :END77 :ERR278 title 错误 - 制作备份79 color 0E80 echo 错误:压缩软件:“%exe7z%”不存在!81 echo.82 echo 请检查7z压缩软件,或者编辑批处理修改exe7z变量。83 echo.84 echo 按任意键退出...85 pause>nul86 goto :END87 :END88 exit
由于某些比较大的项目更新没有WP源码的更新频繁,每次备份较大的项目需要花费的时间较长,所以对上面的代码中Uplayer是分离出来的。
如图:
制作备份_菜单.bat
他会创建 exclude_noUplayer.txt 文件,可手动编辑排除的文件。
1 @echo off 2 echo ====== 制作备份 ====== 3 echo 1. noUplayer 4 echo 2. onlyUplayer 5 echo 3. 全部(onlyUplayer和onlyUplayer) 6 echo 4. 全部 7 echo. 8 set /p key=请选择: 9 if "%key%"=="1" call 制作备份.bat -noUplayer10 if "%key%"=="2" call 制作备份.bat -onlyUplayer11 if "%key%"=="3" start call 制作备份.bat -noUplayer && call 制作备份.bat -onlyUplayer12 if "%key%"=="4" call 制作备份.bat
4. 手动给无线网络启动wifi热点
wifi热点.bat
@echo offrem 请设置简单的无线热点ssid和密码(8位)set ssid=TEMP001set key=88888888rem -------------------------------------"%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\SYSTEM" >nul 2>nulif %errorlevel%==0 goto :startecho 请以管理员身份运行。goto :end:startcolor 1fecho --------------echo 创建wifi热点echo --------------echo.echo 按任意键开始...echo.pause>nulnetsh wlan set hostednetwork mode=allow ssid=%ssid% key=%key%if errorlevel 1 goto :err1echo SSID: %ssid%echo KEY: %key%ping -n 2 127.1>nulecho.netsh wlan start hostednetworkif errorlevel 1 goto :err2ping -n 2 127.1>nulecho 请手动设置网络共享,共享给新创建的wifi热点...start "" ncpa.cplgoto:end:err1echo 配置热点信息失败。goto :end:err2echo 启动热点失败。请尝试:echo 设备管理器 - 网络适配器 - Microsoft virtual WiFI Miniport Adapter(如果有)echo 右键-属性,到“驱动程序”页,点“启用”按钮。start "" devmgmt.mscgoto :end:endecho.echo 按任意键结束...pause>nul