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 ^<Menu^> 21 echo 1.Build 2.Rebuild 3[3].Deploy and Run 4.Update 5.Uninstall 22 echo 6.Dir IsolatedStore 7.Take snapshot 8.Restore snapshot 23 echo 9.Phone Reg Tool L.Open last msbuild log file x.Exit 24 set input= 25 set /p input=Command: 26 if "%input%"=="1" goto :build 27 if "%input%"=="2" goto :rebuild 28 if "%input%"=="3" goto :deploy 29 if "%input%"=="4" goto :update 30 if "%input%"=="5" goto :uninstall 31 if "%input%"=="6" goto :isedir 32 if "%input%"=="7" goto :isets 33 if "%input%"=="8" goto :isers 34 if "%input%"=="9" goto :phonereg 35 if "%input%"=="l" goto :openlogfile 36 if "%input%"=="L" goto :openlogfile 37 if "%input%"=="x" goto :end 38 if "%input%"=="X" goto :end 39 if "%input%"=="exit" goto :end 40 if "%input%"=="33" goto :startAPPDEPLOY 41 goto :menu 42 :build 43 echo Boot Building... 44 echo ^(1/5^) Building UPlayer_WRT.vcxproj ... 45 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_WRT\UPlayer_WRT.vcxproj" 46 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD UPlayer_WRT.vcxproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 47 echo ^(2/5^) Building UPlayer_players.csproj ... 48 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_players\UPlayer_players.csproj" 49 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD UPlayer_players.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 50 echo ^(3/5^) Building Youku.Pattern.csproj ... 51 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Pattern\Youku.Pattern.csproj" 52 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.Pattern.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 53 echo ^(4/5^) Building Youku.Online.csproj ... 54 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Online\Youku.Online.csproj" 55 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.Online.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 56 echo ^(5/5^) Building Youku.csproj ... 57 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku\Youku.csproj" 58 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.csproj ERROR! ^(%ERRORLEVEL%^)) else (echo ALL BUILD OK.) 59 goto :menu 60 :rebuild 61 set /p MYCONSOLE=Rebuild with MYCONSOLE?(Y/N): 62 set DefineConstants= 63 if "%MYCONSOLE%"=="y" set DefineConstants=DefineConstants^=^"MYCONSOLE^"; 64 if "%MYCONSOLE%"=="Y" set DefineConstants=DefineConstants^=^"MYCONSOLE^"; 65 echo Boot Rebuilding... 66 echo ^(1/5^) Rebuilding UPlayer_WRT.vcxproj ... 67 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_WRT\UPlayer_WRT.vcxproj" 68 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD UPlayer_WRT.vcxproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 69 echo ^(2/5^) Rebuilding UPlayer_players.csproj ... 70 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_players\UPlayer_players.csproj" 71 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD UPlayer_players.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 72 echo ^(3/5^) Rebuilding Youku.Pattern.csproj ... 73 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Pattern\Youku.Pattern.csproj" 74 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.Pattern.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 75 echo ^(4/5^) Rebuilding Youku.Online.csproj ... 76 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Online\Youku.Online.csproj" 77 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.Online.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 78 echo ^(5/5^) Rebuilding Youku.csproj ... 79 %MSBUILD% /t:Rebuild /p:%DefineConstants%Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku\Youku.csproj" 80 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.csproj ERROR! ^(%ERRORLEVEL%^)) else (echo ALL REBUILD OK.) 81 goto :menu 82 :deploy 83 echo Deploying. Please wait................. 84 if NOT EXIST %APPDEPLOYCMD% goto noAPPDEPLOYCMD 85 %APPDEPLOYCMD% /installlaunch %XAPFILE% /targetdevice:de 86 if %ERRORLEVEL% EQU 5 goto :startAPPDEPLOY 87 if %ERRORLEVEL% NEQ 0 (echo ^>^> DEPLOY ERROR! ^(%ERRORLEVEL%^)) else (echo DEPLOY OK.) 88 goto :menu 89 :noAPPDEPLOYCMD 90 echo Warnning: AppDeployCmd.exe is not found! 91 :startAPPDEPLOY 92 echo Start AppDeploy.exe ... 93 start "" /d "%folder%\Youku.Bin\Release" %APPDEPLOY% 94 ping -n 2 127.1>nul 95 goto :menu 96 :update 97 echo Updating. Please wait................. 98 if NOT EXIST %APPDEPLOYCMD% goto noAPPDEPLOYCMD 99 %APPDEPLOYCMD% /update %XAPFILE% /targetdevice:de 100 if %ERRORLEVEL% EQU 5 goto :startAPPDEPLOY 101 if %ERRORLEVEL% NEQ 0 (echo ^>^> UPDATE ERROR! ^(%ERRORLEVEL%^)) else (echo UPDATE OK.) 102 goto :menu 103 :uninstall 104 echo Uninstall. Please wait................. 105 if NOT EXIST %APPDEPLOYCMD% (echo Warnning: AppDeployCmd.exe is not found!&&goto :menu) 106 echo ^* Product ID: %PRODUCTID% 107 %APPDEPLOYCMD% /uninstall %PRODUCTID% /targetdevice:de 108 if %ERRORLEVEL% NEQ 0 (echo ^>^> Uninstall ERROR! ^(%ERRORLEVEL%^)) else (echo Uninstall OK.) 109 goto :menu 110 :isedir 111 echo Dir IsolatedStore. Please wait................. 112 echo ^* Product ID: %PRODUCTID% 113 %ISETOOL% dir de %PRODUCTID% 114 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Dir isolated storage ERROR!) else (echo Dir isolated storage OK.) 115 goto :menu 116 :isets 117 echo Take snapshot. Please wait................. 118 echo ^* Product ID: %PRODUCTID% 119 echo ^* Desktop Path: %DESKTOPPATH% 120 %ISETOOL% ts de %PRODUCTID% "%folder%\%DESKTOPPATH%" 121 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Take snapshot ERROR!) else (echo Take snapshot OK.) 122 goto :menu 123 :isers 124 echo Restore snapshot. Please wait................. 125 echo ^* Product ID: %PRODUCTID% 126 echo ^* Desktop Path: %DESKTOPPATH%\IsolatedStore 127 %ISETOOL% rs de %PRODUCTID% "%folder%\%DESKTOPPATH%\IsolatedStore" 128 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Restore snapshot ERROR!) else (echo Restore snapshot OK.) 129 goto :menu 130 :phonereg 131 echo Start PhoneReg.exe ... 132 start "" %PHONEREG% 133 ping -n 2 127.1>nul 134 goto :menu 135 :openlogfile 136 if exist %msbuildlog% (start "" notepad %msbuildlog%) else (echo Logfile not found.) 137 goto :menu 138 :edit 139 start "" notepad "%0" 140 :end 141 popd 142 exit
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 ^<Menu^> 21 echo 1.Build 2.Rebuild 3[3].Deploy and Run 4.Update 5.Uninstall 22 echo 6.Dir IsolatedStore 7.Take snapshot 8.Restore snapshot 23 echo 9.Phone Reg Tool L.Open last msbuild log file x.Exit 24 set input= 25 set /p input=Command: 26 if "%input%"=="1" goto :build 27 if "%input%"=="2" goto :rebuild 28 if "%input%"=="3" goto :deploy 29 if "%input%"=="4" goto :update 30 if "%input%"=="5" goto :uninstall 31 if "%input%"=="6" goto :isedir 32 if "%input%"=="7" goto :isets 33 if "%input%"=="8" goto :isers 34 if "%input%"=="9" goto :phonereg 35 if "%input%"=="l" goto :openlogfile 36 if "%input%"=="L" goto :openlogfile 37 if "%input%"=="x" goto :end 38 if "%input%"=="X" goto :end 39 if "%input%"=="exit" goto :end 40 if "%input%"=="33" goto :startXAPDEPLOY 41 goto :menu 42 :build 43 echo Boot Building... 44 echo ^(1/5^) Building UPlayer_WRT.vcxproj ... 45 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_WRT\UPlayer_WRT.vcxproj" 46 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD UPlayer_WRT.vcxproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 47 echo ^(2/5^) Building UPlayer_players.csproj ... 48 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_players\UPlayer_players.csproj" 49 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD UPlayer_players.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 50 echo ^(3/5^) Building Youku.Pattern.csproj ... 51 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Pattern\Youku.Pattern.csproj" 52 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.Pattern.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 53 echo ^(4/5^) Building Youku.Online.csproj ... 54 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Online\Youku.Online.csproj" 55 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.Online.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 56 echo ^(5/5^) Building Youku.csproj ... 57 %MSBUILD% /t:Build /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku\Youku.csproj" 58 if %ERRORLEVEL% NEQ 0 (echo ^>^> BUILD Youku.csproj ERROR! ^(%ERRORLEVEL%^)) else (echo ALL BUILD OK.) 59 goto :menu 60 :rebuild 61 set /p MYCONSOLE=Rebuild with MYCONSOLE?(Y/N): 62 set DefineConstants= 63 if "%MYCONSOLE%"=="y" set DefineConstants=DefineConstants^=^"MYCONSOLE^"; 64 if "%MYCONSOLE%"=="Y" set DefineConstants=DefineConstants^=^"MYCONSOLE^"; 65 echo Boot Rebuilding... 66 echo ^(1/5^) Rebuilding UPlayer_WRT.vcxproj ... 67 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_WRT\UPlayer_WRT.vcxproj" 68 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD UPlayer_WRT.vcxproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 69 echo ^(2/5^) Rebuilding UPlayer_players.csproj ... 70 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\UPlayer\UPlayer_players\UPlayer_players.csproj" 71 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD UPlayer_players.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 72 echo ^(3/5^) Rebuilding Youku.Pattern.csproj ... 73 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Pattern\Youku.Pattern.csproj" 74 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.Pattern.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 75 echo ^(4/5^) Rebuilding Youku.Online.csproj ... 76 %MSBUILD% /t:Rebuild /p:Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku.Online\Youku.Online.csproj" 77 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.Online.csproj ERROR! ^(%ERRORLEVEL%^)&&goto :menu) 78 echo ^(5/5^) Rebuilding Youku.csproj ... 79 %MSBUILD% /t:Rebuild /p:%DefineConstants%Configuration=Release;Platform=ARM /nologo /noconsolelogger %filelogger% "%folder%\Youku\Youku.csproj" 80 if %ERRORLEVEL% NEQ 0 (echo ^>^> REBUILD Youku.csproj ERROR! ^(%ERRORLEVEL%^)) else (echo ALL REBUILD OK.) 81 goto :menu 82 :deploy 83 echo Deploying. Please wait................. 84 if NOT EXIST %XAPDEPLOYCMD% goto noXAPDEPLOYCMD 85 %XAPDEPLOYCMD% /installlaunch %XAPFILE% /targetdevice:de 86 if %ERRORLEVEL% EQU 5 goto :startXAPDEPLOY 87 if %ERRORLEVEL% NEQ 0 (echo ^>^> DEPLOY ERROR! ^(%ERRORLEVEL%^)) else (echo DEPLOY OK.) 88 goto :menu 89 :noXAPDEPLOYCMD 90 echo Warnning: XapDeployCmd.exe is not found! 91 :startXAPDEPLOY 92 echo Start XapDeploy.exe ... 93 start "" /d "%folder%\Youku.Bin\Release" %XAPDEPLOY% 94 ping -n 2 127.1>nul 95 goto :menu 96 :update 97 echo Updating. Please wait................. 98 if NOT EXIST %XAPDEPLOYCMD% goto noXAPDEPLOYCMD 99 %XAPDEPLOYCMD% /update %XAPFILE% /targetdevice:de 100 if %ERRORLEVEL% EQU 5 goto :startXAPDEPLOY 101 if %ERRORLEVEL% NEQ 0 (echo ^>^> UPDATE ERROR! ^(%ERRORLEVEL%^)) else (echo UPDATE OK.) 102 goto :menu 103 :uninstall 104 echo Uninstall. Please wait................. 105 if NOT EXIST %XAPDEPLOYCMD% (echo Warnning: XapDeployCmd.exe is not found!&&goto :menu) 106 echo ^* Product ID: %PRODUCTID% 107 %XAPDEPLOYCMD% /uninstall %PRODUCTID% /targetdevice:de 108 if %ERRORLEVEL% NEQ 0 (echo ^>^> Uninstall ERROR! ^(%ERRORLEVEL%^)) else (echo Uninstall OK.) 109 goto :menu 110 :isedir 111 echo Dir IsolatedStore. Please wait................. 112 echo ^* Product ID: %PRODUCTID% 113 %ISETOOL% dir de %PRODUCTID% 114 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Dir isolated storage ERROR!) else (echo Dir isolated storage OK.) 115 goto :menu 116 :isets 117 echo Take snapshot. Please wait................. 118 echo ^* Product ID: %PRODUCTID% 119 echo ^* Desktop Path: %DESKTOPPATH% 120 %ISETOOL% ts de %PRODUCTID% "%folder%\%DESKTOPPATH%" 121 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Take snapshot ERROR!) else (echo Take snapshot OK.) 122 goto :menu 123 :isers 124 echo Restore snapshot. Please wait................. 125 echo ^* Product ID: %PRODUCTID% 126 echo ^* Desktop Path: %DESKTOPPATH%\IsolatedStore 127 %ISETOOL% rs de %PRODUCTID% "%folder%\%DESKTOPPATH%\IsolatedStore" 128 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Restore snapshot ERROR!) else (echo Restore snapshot OK.) 129 goto :menu 130 :phonereg 131 echo Start PhoneReg.exe ... 132 start "" %PHONEREG% 133 ping -n 2 127.1>nul 134 goto :menu 135 :openlogfile 136 if exist %msbuildlog% (start "" notepad %msbuildlog%) else (echo Logfile not found.) 137 goto :menu 138 :edit 139 start "" notepad "%0" 140 :end 141 popd 142 exit
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 :setsource 10 title ROBOCOPY %source% dest-dir 11 :setdestination 12 set /p destination=dest-dir: 13 if "%destination%"=="" goto :setdestination 14 if not exist %destination% goto :startrobocopy 15 :overwritequestion 16 set /p key=The dest-dir has existed. Do it?(Y/N): 17 if "%key%"=="" goto :overwritequestion 18 if "%key%"=="Y" goto :startrobocopy 19 if "%key%"=="y" goto :startrobocopy 20 goto :setdestination 21 :startrobocopy 22 title ROBOCOPY %source% %destination% 23 set XF=Thumbs.db 24 set XD=.svn myfiles 25 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 :setsource 10 if not exist %source% echo The source-dir doesn't exist. Please input again.&&goto :setsource 11 :setdestination 12 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 :setdestination 15 if not exist %destination% goto :startrobocopy 16 :overwritequestion 17 set /p key=The dest-dir has existed. Do it?(Y/N): 18 if "%key%"=="" goto :overwritequestion 19 if "%key%"=="Y" goto :startrobocopy 20 if "%key%"=="y" goto :startrobocopy 21 goto :setsource 22 :startrobocopy 23 color 2e 24 set XF=Thumbs.db 25 set XD=.svn myfiles 26 robocopy %source% %destination% /MIR /XF %XF% /XD %XD% 27 if not exist wp8nokiaupdate goto :editAppid 28 echo ^>^> Xcopying wp8nokiaupdate files... 29 xcopy wp8nokiaupdate %destination%\ /s /e /g /h /r /k /y 30 :editAppid 31 rem echo ^>^> Replace AppId, MarketPlaceAppId, IdleDetectionMode, Agree for Terms and Privacy... 32 echo ^>^> Replace AppId, MarketPlaceAppId... 33 set sourceappid=ad00404c17cb662e 34 set nokiaappid=515158cd5f9b803b 35 set sourcemarketplaceappid=cdfb7d0f-825e-40b4-b146-3853a0646994 36 set nokiamarketplaceappid=923aa42b-882c-4815-9c69-b74100cac3c9 37 set replacefile1=%destination%\Youku.Online\YoukuService\YoukuServicePartOne.cs 38 rem set replacefile2=%destination%\Youku\App.xaml.cs 39 rem set replacefile3=%destination%\Youku\Views\UserRegisterPageView.xaml 40 set tempvbs=%~n0_replace_appid.vbs 41 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 >nul 82 del %tempvbs% /q>nul 83 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 :completed 87 echo Completed. 88 title Create Project-Nokia (Completed) 89 echo. 90 color 17 91 set /p key=Press ENTER to open folder... 92 explorer /select,"%destination%\BuildRelease.bat"
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=youku123 11 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.exe 14 set excludeFile=exclude.txt 15 title 制作备份 16 ::参数 17 if "%1"=="-noUplayer" goto :noUplayer 18 if "%1"=="-onlyUplayer" goto :onlyUplayer 19 goto :start 20 :noUplayer 21 title 制作备份 - NO UPLAYER FOLDER 22 set excludeFile=exclude_noUplayer.txt 23 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 :start 25 :onlyUplayer 26 title 制作备份 - ONLY UPLAYER FOLDER 27 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 :start 30 :start 31 cls 32 if "%slnDir%"=="" goto :ERR1 33 if not exist %slnDir% goto :ERR1 34 if not exist %exe7z% goto :ERR2 35 if exist %excludeFile% goto :COMPRESS 36 ::生成excludeFile 37 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 :COMPRESS 58 title 正在备份:%output% 59 if exist %output% del %output% /F /Q 60 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 :END 66 :ERR1 67 title 错误 - 制作备份 68 color 0E 69 echo 错误:源文件夹:“%slnDir%” 不存在! 70 echo. 71 echo 请修改slnDir变量,保存后重试。 72 echo. 73 echo 按任意键开始编辑... 74 pause>nul 75 start "" %windir%\notepad.exe "%~0" 76 goto :END 77 :ERR2 78 title 错误 - 制作备份 79 color 0E 80 echo 错误:压缩软件:“%exe7z%”不存在! 81 echo. 82 echo 请检查7z压缩软件,或者编辑批处理修改exe7z变量。 83 echo. 84 echo 按任意键退出... 85 pause>nul 86 goto :END 87 :END 88 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 -noUplayer 10 if "%key%"=="2" call 制作备份.bat -onlyUplayer 11 if "%key%"=="3" start call 制作备份.bat -noUplayer && call 制作备份.bat -onlyUplayer 12 if "%key%"=="4" call 制作备份.bat
4. 手动给无线网络启动wifi热点
wifi热点.bat
@echo off rem 请设置简单的无线热点ssid和密码(8位) set ssid=TEMP001 set key=88888888 rem ------------------------------------- "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\SYSTEM" >nul 2>nul if %errorlevel%==0 goto :start echo 请以管理员身份运行。 goto :end :start color 1f echo -------------- echo 创建wifi热点 echo -------------- echo. echo 按任意键开始... echo. pause>nul netsh wlan set hostednetwork mode=allow ssid=%ssid% key=%key% if errorlevel 1 goto :err1 echo SSID: %ssid% echo KEY: %key% ping -n 2 127.1>nul echo. netsh wlan start hostednetwork if errorlevel 1 goto :err2 ping -n 2 127.1>nul echo 请手动设置网络共享,共享给新创建的wifi热点... start "" ncpa.cpl goto:end :err1 echo 配置热点信息失败。 goto :end :err2 echo 启动热点失败。请尝试: echo 设备管理器 - 网络适配器 - Microsoft virtual WiFI Miniport Adapter(如果有) echo 右键-属性,到“驱动程序”页,点“启用”按钮。 start "" devmgmt.msc goto :end :end echo. echo 按任意键结束... pause>nul