博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
开发过程中编写的一些批处理
阅读量:4702 次
发布时间:2019-06-09

本文共 24663 字,大约阅读时间需要 82 分钟。

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 ^
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:de100 if %ERRORLEVEL% EQU 5 goto :startAPPDEPLOY101 if %ERRORLEVEL% NEQ 0 (echo ^>^> UPDATE ERROR! ^(%ERRORLEVEL%^)) else (echo UPDATE OK.)102 goto :menu103 :uninstall104 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:de108 if %ERRORLEVEL% NEQ 0 (echo ^>^> Uninstall ERROR! ^(%ERRORLEVEL%^)) else (echo Uninstall OK.)109 goto :menu110 :isedir111 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 :menu116 :isets117 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 :menu123 :isers124 echo Restore snapshot. Please wait.................125 echo ^* Product ID: %PRODUCTID%126 echo ^* Desktop Path: %DESKTOPPATH%\IsolatedStore127 %ISETOOL% rs de %PRODUCTID% "%folder%\%DESKTOPPATH%\IsolatedStore"128 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Restore snapshot ERROR!) else (echo Restore snapshot OK.)129 goto :menu130 :phonereg131 echo Start PhoneReg.exe ...132 start "" %PHONEREG%133 ping -n 2 127.1>nul134 goto :menu135 :openlogfile136 if exist %msbuildlog% (start "" notepad %msbuildlog%) else (echo Logfile not found.) 137 goto :menu138 :edit139 start "" notepad "%0"140 :end141 popd142 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 ^
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:de100 if %ERRORLEVEL% EQU 5 goto :startXAPDEPLOY101 if %ERRORLEVEL% NEQ 0 (echo ^>^> UPDATE ERROR! ^(%ERRORLEVEL%^)) else (echo UPDATE OK.)102 goto :menu103 :uninstall104 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:de108 if %ERRORLEVEL% NEQ 0 (echo ^>^> Uninstall ERROR! ^(%ERRORLEVEL%^)) else (echo Uninstall OK.)109 goto :menu110 :isedir111 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 :menu116 :isets117 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 :menu123 :isers124 echo Restore snapshot. Please wait.................125 echo ^* Product ID: %PRODUCTID%126 echo ^* Desktop Path: %DESKTOPPATH%\IsolatedStore127 %ISETOOL% rs de %PRODUCTID% "%folder%\%DESKTOPPATH%\IsolatedStore"128 ::if %ERRORLEVEL% NEQ 0 (echo ^>^> Restore snapshot ERROR!) else (echo Restore snapshot OK.)129 goto :menu130 :phonereg131 echo Start PhoneReg.exe ...132 start "" %PHONEREG%133 ping -n 2 127.1>nul134 goto :menu135 :openlogfile136 if exist %msbuildlog% (start "" notepad %msbuildlog%) else (echo Logfile not found.) 137 goto :menu138 :edit139 start "" notepad "%0"140 :end141 popd142 exit
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

 

转载于:https://www.cnblogs.com/Bob-wei/p/4489412.html

你可能感兴趣的文章
学号 《信息安全系统设计基础》第6周学习总结(一)
查看>>
alpha阶段个人总结
查看>>
不透明度opacity进阶
查看>>
C++代码中回调JS方法
查看>>
(WPF) MVVM: 动态添加控件及绑定。
查看>>
SQL中的charindex()方法
查看>>
地图坐标相关计算
查看>>
我一定会成功的!
查看>>
INFORMATICA 的调优之一 源数据的优化
查看>>
MyEclipse中配置tomcat
查看>>
C# 实现对接电信交费易自动缴费
查看>>
斐波那契数列-兔子问题
查看>>
03007_HttpServlet
查看>>
java中经常使用的Swing组件总结
查看>>
EnoroF's Game Engine
查看>>
aar jar包打包
查看>>
Kettle
查看>>
基础知识1----传值方式调用函数--请输出结果
查看>>
day6 bytes类型用法
查看>>
源码 补码以及反码
查看>>