2009-03-31 4 views

답변

7

키는 기본 제공 "_CopyWebApplication"대상을 사용하는 것입니다.

/project.build 
/src/myprojct.sln 
/src/myporject.web/myproject.web.csproj 
/output 

편집 : 여기

난의 디렉토리 구조

<target name="compile" description="Compiles the project."> 
     <exec basedir="." program="${DotNetPath}msbuild.exe" commandline=" src/MyProject.Web/MyProject.Web.csproj /nologo 
    /t:Rebuild 
    /t:ResolveReferences;_CopyWebApplication 
    /p:OutDir=../../output/build/bin/ 
    /p:WebProjectOutputDir=../../output/build/ 
    /p:Debug=${debug} 
    /p:Configuration=${configuration} 
    /v:m" 
    workingdir="." failonerror="true" /> 
    </target> 

을 할 것입니다 나는 또한 내 CSS와 JS를 압축하는 유이 압축을 사용하려면이 옵션을 사용

<target name="compress-js"> 
     <foreach item="File" property="filename"> 
      <in> 
       <items basedir="output/build/assets/javascript/"> 
        <include name="/**/*.js" /> 
        <exclude name="/**/*.min.js" /> 
        <exclude name="/**/*.pack.js" /> 
       </items> 
      </in> 
      <do> 
       <exec basedir="." program="${JavaPath}java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type js --charset utf-8 -o &quot;${filename}&quot; &quot;${filename}&quot;" failonerror="true" /> 
      </do> 
     </foreach> 
    </target> 


    <target name="compress-css" depends="combine-css"> 
     <foreach item="File" property="filename"> 
      <in> 
       <items basedir="output/build/assets/css/"> 
        <include name="/**/*.css" /> 
        <exclude name="/**/*.min.css" /> 
        <exclude name="/**/*.pack.css" /> 
       </items> 
      </in> 
      <do> 
       <exec basedir="." program="S:\Java\jdk1.6.0_11\bin\java" commandline=" -jar S:\yuicompressor-2.4.1\build\yuicompressor-2.4.1.jar --type css --charset utf-8 -o &quot;${filename}&quot; &quot;${filename}&quot;" failonerror="true" /> 
      </do> 
     </foreach> 
    </target> 
5

MSBuild를 사용하면 NAnt를 사용하는 목적에 이깁니다. NAnt는 MSBuild를 대체하는 것으로, 아래를 사용하여 깨끗한 NAnt comp VS 2003/2005/2008에서와 같이 웹 응용 프로그램 프로젝트의 확장.

나를 위해 작동합니다!

<property name="debug" value="AutomatedDebug" /> 
<property name="configuration" value="Debug;TargetFrameworkVersion=v3.5" /> 

    <msbuild project="src\WebApplication1\WebApplication1.csproj" failonerror="true"> 
     <arg value="/nologo" /> 
     <arg value="/t:Rebuild" /> 
     <arg value="/t:ResolveReferences;_CopyWebApplication" /> 
     <arg value="/p:OutDir=../../build/Debug/WebApplication/" /> 
     <arg value="/p:WebProjectOutputDir=../../build/Debug/WebApplication-Deploy/" /> 
     <arg value="/p:Debug=${debug}" /> 
     <arg value="/p:Configuration=${configuration}" /> 
     <arg value="/v:m" /> 
    </msbuild> 

이 그냥 비주얼 스튜디오 내에서 기능을 "게시"를 사용처럼 배포 폴더에 웹 응용을 컴파일 : 여기

<?xml version="1.0"?> 
<project name="MyTest" default="run"> 
    <property name="basename" value="MyTest1x"/> 
    <property name="debug" value="false"/> 
    <property name="copytarget" value="c:\temp"/> 

    <target name="clean"> 
     <delete> 
      <fileset basedir="${copytarget}"> 
       <include name="bin/${basename}.dll"/> 
       <include name="**/*.???x"/> 
       <include name="Web.config"/> 
      </fileset> 
     </delete> 
    </target> 

    <target name="build"> 
     <mkdir dir="${copytarget}/bin" /> 
     <csc target="library" output="${copytarget}/bin/${basename}.dll" > 
      <sources> 
       <include name="*.cs"/> 
      </sources> 
     </csc> 
    </target> 

    <target name="run" depends="clean,build"> 
    <copy todir="${copytarget}" overwrite="true"> 
     <fileset basedir="."> 
      <include name="**/*.???x" /> 
      <include name="Web.config" /> 
      </fileset> 
     </copy> 
    </target> 
</project> 
2

는 NANT에 대한 MSBUILD 작업을 사용하여 그것을 할 수있는 방법입니다 .

3

저는 이것이 낡은 질문이지만, 방금 배운 것을 알았 기 때문에 공유 할 것을 결정했습니다. "_CopyWebApplication"대상이 존재하고 작동하는 것은 100 % 사실이지만 .NET 4.0에서는 web.config 변환 구문 등과 같은 새로운 기능을 지원하는 Microsoft.Web.Publishing.targets의 "_WPPCopyWebApplication"대상으로 대체되었습니다.

(이와 비슷하게 모든 질문에 다시 게시되므로이 항목에 대해 투표하지 마십시오. :))

+0

나는이 답변이 나에게 많은 도움이되었지만 대답의 맨 아래에 제대로 보관할 자격이 없다는 것을 알고있다. . :) – Matt

관련 문제