Error copying files from successful build using command line or artifact

Hi all,

I have built a new server with TeamCity v9.0. I am having difficulty trying to copy the build output to a mapped network drive


My build steps are as follows:
  1. Get latest version from TFS online.
  2. Build using MSBuild
  3. Run NUnit tests
  4. Copy two folders (Web and ServiceLayer) to a mapped network drive

Attempted but can not get working:

  1. Created a final build step with the following
    Command Line

xcopy\ServiceLayer\ D:\ServiceLayer\ /S /Y
xcopy\Web\ D:\Web\ /S /Y


Step 4/5: Copy build output to web and api on staging (Command Line)
teamcity[buildStatisticValue key='buildStageDuration:firstStepPreparation' value='70.0']
teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_8' value='0.0'] Starting:
in directory: D:\TeamCity\buildAgent\work\3b1161c630069aad 0 File(s)
copied Invalid path Process exited with code 4
teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_8' value='194.0'] Step Copy
build output to web and api on staging (Command Line) failed

  1. Created an artifact path

    ServiceLayer => d:\Temp\


Failed to publish artifacts: Failed to upload artifact, due to error: Failed to create directory:
"C:\ProgramData\JetBrains\TeamCity\system\artifacts\ChannelOptimiser40\CO40 Build Config\224\d:\Temp"

Can someone please tell me how I can copy my

folders to another directory when the build completes?
Comment actions Permalink

Please check that the user that TC agent is running under has an access to the required environment, such as mapped drive, etc.

Comment actions Permalink

Hi Sergey,

I am running TeamCity from a Microsoft Windows Server 2012, so would the following steps be correct:

  1. Change the Windows Service (TeamCity Build Agent)
  2. Use the Administrator account in "Log On" properties window of that service.
  3. Restart the TeamCity Build Agent Service

Thanks in advance

Comment actions Permalink

As far as I remember, mapped drive is only valid within user session. I think you need to create a persistent mapping, as suggested here: Or if you map drive to folder, there is another (but similar) procedure.

Comment actions Permalink

Thanks for the help Sergey.

I used the UNC path and changed the account that runs the Windows Service.

The files are now being copied to the directory.


Please sign in to leave a comment.