编写批处理文件编译.Net工程

来源:互联网 发布:网络消费 编辑:程序博客网 时间:2024/05/29 10:47

使用随Visual Studio一块安装的devenv.com,再加上参数可以对.Net进行编译,如下

  "D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com"  d:\Projects\YourProject.csproj  /rebuild "Release"

 "D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com"  ".\Share\Projects\DGShare.sln" /rebuild Release  /Out .\build_log\DGShare.log

当然,你也可以编写批处理文件来对.net的解决方案(.sln)进行编译,如下

path %path%;c:\Program Files\Microsoft Visual Studio 8\Common7\IDE

devenv.com c:\solution1\solution1.sln /rebuild "Release" 
devenv.com c:\solution2\solution2.sln /rebuild "Release" 
devenv.com c:\solution3\solution3.sln /rebuild "Release"

...

第一份例子

@echo off
set time1=%TIME%
dir | find "build_log"  > nul      
if %errorlevel%==0 goto end       REM--如果有就跳到:end
if %errorlevel%==1 goto create    REM--如果没就跳到:create
:create
md build_log
:end

path %path%;D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE

devenv.com  ".\Share\Projects\DGShare.sln" /rebuild Debug  /Out .\build_log\DGShareD.log
devenv.com  ".\Taurus\Projects\Taurus.sln" /rebuild Debug  /Out .\build_log\TaurusD.log
devenv.com ".\DreamStudio\Projects\DreamStudio.sln" /rebuild Debug  /Out .\build_log\DreamStudioD.log
REM devenv.com ".\DreamGame\Client\Projects\DGClient.sln" /rebuild Debug  /Out .\build_log\DGClientD.log

@echo off
echo 开始时间:%time1%
echo 结束时间:%TIME%

pause

第二份例子:
@echo off


:: 手动发布sdk和工具到 build 服务器(编译服务无法使用的情况下)


set build_ver=Alpha4


echo 正在更新...


echo .


echo 拷贝 SDK 库和头文件...


xcopy /y /r /s /q D:\DGSource\DG_Game\Project2009\branches\%build_ver%\Share\SDK\Include\*.* \\build\c$\Products\Output\%build_ver%\Debug\SDK\include\
xcopy /y /r /s /q D:\DGSource\DG_Game\Project2009\branches\%build_ver%\Taurus\SDK\Include\*.* \\build\c$\Products\Output\%build_ver%\Debug\SDK\include\
xcopy /y /r /s /q D:\DGSource\DG_Game\Project2009\branches\%build_ver%\Share\SDK\Include\*.* \\build\c$\Products\Output\%build_ver%\Release\SDK\include\
xcopy /y /r /s /q D:\DGSource\DG_Game\Project2009\branches\%build_ver%\Taurus\SDK\Include\*.* \\build\c$\Products\Output\%build_ver%\Release\SDK\include\


xcopy /y /r /s /q %~dp0\%build_ver%\Debug\SDK\lib\*.* \\build\c$\Products\Output\%build_ver%\Debug\SDK\lib\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\SDK\lib\*.* \\build\c$\Products\Output\%build_ver%\Release\SDK\lib\


echo 拷贝公共 COM 组件...


xcopy /y /r /s /q %~dp0\%build_ver%\Debug\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\COM\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Debug\GameWorld\COM\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Debug\TaurusDebug\COM\


xcopy /y /r /s /q %~dp0\%build_ver%\Release\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\COM\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Release\GameWorld\COM\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\GameWorld\COM\*.* \\build\c$\Products\Output\%build_ver%\Release\TaurusDebug\COM\


echo 拷贝编辑器等工具...


xcopy /y /r /s /q %~dp0\%build_ver%\Debug\TaurusDebug\*.exe \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\DreamStudio\*.exe \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\DreamStudio\*.dll \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\DreamStudio\*.ocx \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Debug\DreamStudio\ModulesD\*.* \\build\c$\Products\Output\%build_ver%\Debug\DreamStudio\ModulesD\


xcopy /y /r /s /q %~dp0\%build_ver%\Release\TaurusDebug\*.exe \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\DreamStudio\*.exe \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\DreamStudio\*.dll \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\DreamStudio\*.ocx \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\
xcopy /y /r /s /q %~dp0\%build_ver%\Release\DreamStudio\Modules\*.* \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\Modules\


xcopy /y /r D:\DGSource\DG_Game\Project2009\branches\%build_ver%\DreamStudio\Projects\DreamStudio\update.ini \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\
xcopy /y /r D:\DGSource\DG_Game\Project2009\branches\%build_ver%\DreamStudio\Projects\DreamStudio\update.txt \\build\c$\Products\Output\%build_ver%\Release\DreamStudio\


echo .
echo 更新完毕!
echo .
pause 

原创粉丝点击