aspnet_compiler and NAnt : target directory is not empty RRS feed

  • Question

  • User737389583 posted

     Hello everybody,

     this is my first post here.  I intend to create a Nant script in order to compile my web site and then publish it to some target folder.
    My web site is quite huge (2 Go), this because mostly of assets such as flash video, images,  and so on...

    I have the Nant script detailed below and get on a "target directory is not empty" error  when using aspnet_compiler. My point is that I do not want to copy all the files of my web site every time I am making a precompilation of my web site. It would be far too slow. Is there any argument I might pass on the command line in order to make an incremental build?

     Thanks for any light on the matter, i am rather in the dark , right now...


    <?xml version="1.0"?>
    <project name="cultur" default="Deploy" basedir="." xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd">

      <loadtasks assembly="C:\Program Files\nant\nantcontrib-0.86-nightly-2009-02-01\bin\NAnt.Contrib.Tasks.dll" />

      <property name="SolutionName" value="cultur.sln" />

      <property name="BaseDir" value = ".\" />
      <property name="aspx.dir" value="${BaseDir}\ApplicationWeb\" />
      <property name="LocalIIS.dir" value="${BaseDir}\IIS\" />
      <property name="Deploy.dir" value="${BaseDir}\Deploy\"   />

      <property name="BuildType" value="Release" />
      <property name="msbuildArgs" value="/p:WarningLevel=4;Configuration=${BuildType}" />

      <target name="build" description="Compilation of the solution" >
                commandline="${SolutionName} ${msbuildArgs}"
      <target name="Precompile" description="PreCompilation of the aspx file"  depends="build">
        <mkiisdir dirpath="${LocalIIS.dir}" vdirname="aspprecompile" />
        <exec program="C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe" useruntimeengine="true">
          <arg value="-p" />
          <arg value="${aspx.dir}" />     
          <arg value="-u" />
          <arg value="-fixednames" />
          <arg value="-v" />
          <arg value="aspprecompile" />
          <arg value="${LocalIIS.dir}" />
        <deliisdir vdirname="aspprecompile" />

      <target name="Deploy" Description="Copy new files to deploy folder" depends="Precompile" >
        <copy todir="${Deploy.dir}">
          <fileset basedir="${LocalIIS.dir}">
            <include name="**" />


    Monday, May 18, 2009 5:37 AM


  • User372121194 posted


    You can use aspnet_compiler.exe command line to precompile your website and place OutPut in local, and then upload the required files to server.

    You can try to use Web Deployment project (http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx), which allows you to remove the file such as flash in BeforeBuild Target and then copy them back in AfterBuild Target.

    For example:

      <Target Name="BeforeBuild">
      <Target Name="AfterBuild">

    I look forward to receiving your test results.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 21, 2009 5:29 AM