Using Nant 0.92 (and earlier 0.85 with the same effect)
I am trying to invoke the uninstall task in NAnt to delete all files except the .dll file after calling msbuild (see below script .. I mean uninstalling in the target line “build”). The uninstall task does not seem to be running.
The original uninstall task works fine and behaves as expected, deleting all files from the specified assembly directory. The second uninstall task after compilation, however, does not work.
I tried just deleting everything (without using the exclude tag), tried to explicitly set failonerror and verbose to true. None of this matters. I also tried to use sleep to stop the process before the deletion task, in case something in msbuild did not delete files during deletion. I tried to put the deletion in a separate target, still no luck.
The command obviously works before msbuild is called, and it works after msbuild if it tries to remove msbuild from a directory other than the output target (i.e. copy the output files and then delete the corresponding files).
I'm sure this is too fundamental a problem to be a mistake, but I thought I would ask anyway. Of course, I will use a workaround when you simply copy files to another location, delete what I do not need, and then move accordingly, but I'm interested.
I suspect that if this is a design behavior (although I cannot find anything in the NAnt documentation to suggest that it is), then maybe the msbuild process blocks the output files until the NAnt process exits? This is my best guess. Further understanding will be appreciated.
EDIT: also, if I explicitly set the \ OutputPath switch for msbuild, then I don't have the same problem. It seems that when OutputPath is used by default, a problem is created.
NAnt build file:
<?xml version="1.0" encoding="utf-8" ?> <project name="Reports.TestBench.PreBuild" default="postbuild.cleanup" basedir="." xmlns="http://nant.sourceforge.net/release/0.86-beta1/nant.xsd"> <property name="nant.settings.currentframework" value="net-4.0" /> <property name="project.StandardReports" value="${project::get-base-directory()}\Reports.StandardReports\Palladium.Reports.StandardReports.csproj" /> <property name="output.Dir" value="${project::get-base-directory()}\bin\debug\"/> <property name="build.Type" value="debug"/> <target name="clean"> <delete> <fileset basedir="${output.Dir}"> <include name="*.*" /> </fileset> </delete> </target> <target name="build" depends="clean" description="Build the Palladium Reports Standard Reports application"> <msbuild project="${project.StandardReports}"> <arg value="/p:Configuration=${build.Type}" /> <arg value="/t:Rebuild" /> </msbuild> <delete failonerror="true" verbose="true"> <fileset basedir="${output.Dir}"> <include name="*.*" /> <exclude name="Palladium.Reports.StandardReports.dll" /> </fileset> </delete> </target> </project>
Summary of NAnt's output showing build success without further communication:
[msbuild] Build succeeded. [msbuild] 0 Warning(s) [msbuild] 0 Error(s) [msbuild] [msbuild] Time Elapsed 00:00:03.19 BUILD SUCCEEDED Total time: 3.5 seconds.