I'm having a problem with the copy task failing (System.UnauthorizedAccessException) when it tries to copy two seperate instances of the same file to one destination.  I've got a simple copy task that is supposed to consolidate the bin directories from multiple projects into one common bin directory, but when it tries to overwrite a copy of a file that was copied earlier in the task it fails.  It appears that the copy task holds some sort of a lock on all the files it creates until the entire job completes...
 
Here is my script:
 
  <copy todir="${build.dir}\bin" overwrite="true" flatten="true" verbose="true" failonerror="false">
   <fileset basedir="${src.dir}">
    <include name="**\bin\${build.config}\*.*" />
   </fileset>
  </copy>
 
An here is the error that is thrown:
 
 [copy] C:\AutomatedBuilds\Libraries\src\Solutions\Libraries\common.footer.build(5,4): Cannot copy 'C:\AutomatedBuilds\Libraries\src\Development\Libraries\Livescan.AdministrationService.Auditing\bin\Debug\Aware.AwWsq1000.dll' to 'C:\AutomatedBuilds\Libraries\build\bin\Aware.AwWsq1000.dll'.: NAnt.Core.BuildException: C:\AutomatedBuilds\Libraries\src\Solutions\Libraries\common.footer.build(5,4): Cannot copy 'C:\AutomatedBuilds\Libraries\src\Development\Libraries\Livescan.AdministrationService.Auditing\bin\Debug\Aware.AwWsq1000.dll' to 'C:\AutomatedBuilds\Libraries\build\bin\Aware.AwWsq1000.dll'. ---> System.UnauthorizedAccessException: Access to the path "C:\AutomatedBuilds\Libraries\build\bin\Aware.AwWsq1000.dll" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at NAnt.Core.Util.FileUtils.CopyFile(String sourceFileName, String destFileName, FilterChain filterChain, Encoding inputEncoding, Encoding outputEncoding) at NAnt.Core.Tasks.CopyTask.DoFileOperations() --- End of inner exception stack trace --- at NAnt.Core.Tasks.CopyTask.DoFileOperations() at NAnt.Core.Tasks.CopyTask.ExecuteTask() at NAnt.Core.Task.Execute()
 
Problems:
1. Even though overwrite="true" is fails to overwrite the previously copied file with a different instance of the same file.\.
2. Even though failonerror="false" the task aborts, and none of the other files are copied.
 
Is anybody aware of a work around for this that does not involve me creating a seperate copy tast for each of my source projects (I'm consolidating 83 projects).
 
Thanks-
 
-EAB

Reply via email to