Bob Palmer
Bob Palmer

Reputation: 4762

Team Build 2008/MSBuild Copy Task throwing error when attempting to copy files

As part of an automated build, I clear out a directory, and copy the latest versions of the source files to this directory. First, I set up the list of files I wish to copy:

    <CreateItem
         Include="\\BuildServer\Build_Temp\SomeRootDirectory\**\*">
        <Output
           TaskParameter ="Include"
           ItemName ="FilesToCopy"/>
    </CreateItem>

And let my system know where my QA server is located at:

    <CreateProperty
          Value="\\QAWebServer\Websites\MySite">
        <Output
            TaskParameter="Value"
            PropertyName ="MyDropLocation"/>
    </CreateProperty>

I then remove and recreate my directory on the destination server to wipe out all files (this is a scorched earth build to make sure we're not accidentally leaving files not part of source control in our web directory).

    <RemoveDir Directories="\\QAWebServer\Websites\MySite"  />
    <MakeDir Directories="\\QAWebServer\Websites\MySite"  />

Finally, I execute a copy task:

    <Copy
            SourceFiles="@(FilesToCopy)"
            DestinationFiles="@(FilesToCopy->'$(MyDropLocation)\%(RecursiveDir)%(Filename)%(Extension)')"
            OverwriteReadOnlyFiles="True"/>

I then get the resulting error as it attempts to copy files. Interestingly, some make it and some don't (in this case, it looks like almost exclusively ones in the root of the directory I just created above):

  C:\Build_Temp\QABuild\BuildType\TFSBuild.proj(690,3): error MSB3021: Unable to copy file "\\BuildServer\Build_Temp\SomeRootDirectory\Import.swf" to "\\QAWebServer\Websites\MySite\Import.swf". Access to the path '\\QAWebServer\Websites\MySite\Import.swf' is denied.
  C:\Build_Temp\QABuild\BuildType\TFSBuild.proj(690,3): error MSB3021: Unable to copy file "\\BuildServer\Build_Temp\SomeRootDirectory\Incomplete.swf" to "\\QAWebServer\Websites\MySite\Incomplete.swf". Access to the path '\\QAWebServer\Websites\MySite\Incomplete.swf' is denied.
  C:\Build_Temp\QABuild\BuildType\TFSBuild.proj(690,3): error MSB3021: Unable to copy file "\\BuildServer\Build_Temp\SomeRootDirectory\Index.html" to "\\QAWebServer\Websites\MySite\Index.html". Access to the path '\\QAWebServer\Websites\MySite\Index.html' is denied.

I've verified access rights to the filesystem (Everyone has access to create/modify/etc.), and there are no issues adding the files to the subdirectory structure on \QAWebServer\Websites\MySite, just (primarilly) to the root.

Upvotes: 1

Views: 967

Answers (1)

Bob Palmer
Bob Palmer

Reputation: 4762

We finally had to fix this by switching over to an XCopy task.

<Exec Command="xcopy /E /R /Y \\buildMachine\Build_Temp\BuildSource
 \\QAWebServer\Websites\MySite"/>

Upvotes: 1

Related Questions