使用NAnt发布WebApplication

raf*_*fek 4 nant publish build

是否可以使用NAnt在解决方案上完成发布(如在Web应用程序项目上的Visual Studio发布中)?我只是找不到解决方案.

And*_*ock 7

它们的关键是使用内置的"_CopyWebApplication"目标.

这就是我做的

<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>
Run Code Online (Sandbox Code Playgroud)

与dir结构:

/project.build
/src/myprojct.sln
/src/myporject.web/myproject.web.csproj
/output
Run Code Online (Sandbox Code Playgroud)

编辑:我也使用它来使用YUI压缩来压缩我的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>
Run Code Online (Sandbox Code Playgroud)


Bin*_*ony 5

使用MSBuild胜过使用NAnt的目的,NAnt取代了MSBuild,使用下面的代码来完成Web应用程序项目的干净NAnt编译,如VS 2003/2005/2008中所述.

这个对我有用!

<?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>
Run Code Online (Sandbox Code Playgroud)