如何编译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文件
 

 

 

 

  

 

 

         

转载于:https://www.cnblogs.com/skycoder/p/6182819.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值