2009-03-31 16 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を圧縮するYUI圧縮を使用するためにこれを使用

<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を実行しますVS 2003/2005/2008のようなWebアプリケーションプロジェクトの縮小。

それは私のために働く!ここで

<?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タスクを使用してそれを行うことができる方法である。

<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> 

これはただのVisual Studio内から「公開」機能を使用するように、展開可能なフォルダに説明WebApplicationをコンパイルします。 。

3

これは古い質問ですが、私はちょうど何かを学んだので、私は共有することにしました。 "_CopyWebApplication"ターゲットが存在し、動作することは100%真実ですが、.NET 4.0ではWeb.config変換構文などの新機能をサポートするMicrosoft.Web.Publishing.targetsの "_WPPCopyWebApplication"ターゲットに取って代わられます。

(同様の言葉の質問にすべて再投稿しますので、この1つに投票しないでください:))

+0

私はあなたがこの1つに投票してくれないと知っていると知っていますが、この回答は私を大いに助けました。そして、それは主要な答えの補足であっても答えの一番下に詰め込まれるに値するものではありません。 :) – Matt

関連する問題