首页 > 代码库 > 如何编译C#的web项目 (C# Compilation Scripts)
如何编译C#的web项目 (C# Compilation Scripts)
本人只是新手,学博客只是只是用于记录学习的点点滴滴,写的不好,多多包涵。
一,如何用batch文件compile C# web Project。
1.新建bat文件,这里是一个例子。
@ECHO OFF REM **************************************************************************** REM SET ALL ENVIRONMENT HERE REM **************************************************************************** @ECHO SETTING ENVIRONMENTS rem SET FRAMEWORKROOT=%systemroot%\microsoft.net\framework\v4.0.30319 SET FRAMEWORKROOT=C:\Windows\Microsoft.NET\Framework\v4.0.30319 set path=%path%;%FRAMEWORKROOT% set BEOUTPUTPATH=C:\MobileOne\M1TechnicalInterface rem set CrystalReport="C:\Program Files\Common Files\Crystal Decisions\1.1\Managed" set FASCADE_OUTPUTPATH=C:\MobileOne\M1TechnicalInterface set OUTPUTPATH=D:\Compilation\Output\AddressLabel\CAL rem set OUTPUTPATH=C:\MobileOne\output set OUTNAME=CAL REM common reference E:\M1TechnicalInterface\bin rem SET AJAXEXTENTION=C:/"Program Files"/"Microsoft ASP.NET"/"ASP.NET 2.0 AJAX Extensions"/v1.0.61025/System.Web.Extensions.dll rem set AJAXCONTROL=%OUTPUTPATH%\%OUTNAME%\bin\AjaxControlToolkit.dll set Common=%OUTPUTPATH%\bin\Common.dll rem set Oracle=%OUTPUTPATH%\bin\Oracle.DataAccess.dll SET WSREFERENCE=%Common%,%Oracle% rem SET WSREFERENCE=%AJAXCONTROL% REM **************************************************************************** REM REMOVE ALL OLD FILES REM **************************************************************************** @ECHO REMOVING EXISTING COMPILAION OUTPUT @ECHO REMOVING DIRECTIORY %OUTPUTPATH% rem rmdir /S /Q %OUTPUTPATH% rmdir /S /Q %OUTPUTPATH% REM **************************************************************************** REM CREATING ALL NEW DIRECTORIES TO STORE OUTPUT REM **************************************************************************** @ECHO CREATING NEW DIRECTORIES REM make PSFrontEnd folder mkdir %OUTPUTPATH% if not "%ERRORLEVEL%" == "0" GOTO :ERROR rem This directory is not needed for PS rem mkdir %OUTPUTPATH%\bin rem if not "%ERRORLEVEL%" == "0" GOTO :ERROR @ECHO COMPILING %OUTPUTPATH% LIBRARY mkdir %OUTPUTPATH%\bin if not "%ERRORLEVEL%" == "0" GOTO :ERROR mkdir %OUTPUTPATH%\images if not "%ERRORLEVEL%" == "0" GOTO :ERROR mkdir %OUTPUTPATH%\Css if not "%ERRORLEVEL%" == "0" GOTO :ERROR mkdir %OUTPUTPATH%\Properties if not "%ERRORLEVEL%" == "0" GOTO :ERROR mkdir %OUTPUTPATH%\scripts if not "%ERRORLEVEL%" == "0" GOTO :ERROR copy *.aspx %OUTPUTPATH% copy *.asax %OUTPUTPATH% copy *.ascx %OUTPUTPATH% copy *.config %OUTPUTPATH% copy *.css %OUTPUTPATH% copy *.js %OUTPUTPATH% copy *.xml %OUTPUTPATH% copy *.html %OUTPUTPATH% copy *.htm %OUTPUTPATH% copy *.Master %OUTPUTPATH% copy bin\*.dll %OUTPUTPATH%\bin copy images\*.* %OUTPUTPATH%\images copy Css\*.* %OUTPUTPATH%\Css copy scripts\*.* %OUTPUTPATH%\scripts copy Properties\*.Settings.settings %OUTPUTPATH%\Properties @ECHO. @ECHO ------------------------------------------------------------- @ECHO. rem csc /nologo /t:library /out:%OUTPUTPATH%\bin\%OUTNAME%.dll *.cs "Web References"\Customer\*.cs "Web References"\SingleSignOnServiceFacade\*.cs "Service References"\Voucher\*.cs "Web References"\SMS\*.cs "Web References"\DASTranLog\*.cs "Properties"\*.cs "Service References"\CAMBFC\*.cs "Service References"\CommonBFC\*.cs "Service References"\Offer\*.cs csc /nologo /t:library /r:%OUTPUTPATH%\bin\Common.dll /r:%WSREFERENCE% /out:%OUTPUTPATH%\bin\%OUTNAME%.dll *.cs "BusinessLogic"\*.cs "Properties"\*.cs "Service References"\InboundCAMBFCService\*.cs "Web References"\ServiceFacada\*.cs "Models"\*.cs if not "%ERRORLEVEL%" == "0" GOTO :ERROR @ECHO. @ECHO ------------------------------------------------------------- @ECHO. @ECHO WEB SERVICES COMPILATION SUCCESSFUL GOTO :END :ERROR @ECHO COMPILATION FAILED :END PAUSE
2. Explanation of bat command
@ECHO 显示打印信息
SET FRAMEWORKROOT=C:\Windows\Microsoft.NET\Framework\v4.0.30319 设置你的Framework的compiler路径。
SET path=%path%;%FRAMEWORKROOT%
SET Common=%OUTPUTPATH%\bin\Common.dll 设置你项目的reference
csc /nologo /t:library /r:%OUTPUTPATH%\bin\Common.dll /r:%WSREFERENCE% /out:%OUTPUTPATH%\bin\%OUTNAME%.dll *.cs "BusinessLogic"\*.cs "Properties"\*.cs "Service References"\InboundCAMBFCService\*.cs "Web References"\ServiceFacada\*.cs "Models"\*.cs
开始compile, /t:library compile完成生成dll文件 /r:添加你的reference /out: 输出dll文件
"BusinessLogic"\*.cs 定义你项目里的cs文件
如何编译C#的web项目 (C# Compilation Scripts)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。